|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
ubaldo Smarty Regular
Joined: 21 Apr 2003 Posts: 35 Location: Barcelona, Spain
|
Posted: Fri Jul 25, 2003 9:11 am Post subject: eval: missing 'var' parameter (erratic) |
|
|
Sometimes I see that eval function throws an error
I can't figure out the circumstances in which this could be triggerd, I mean, none on the templates (and included templates) have an empty eval, e.g. {eval} See code snippet below.
This error happens once in a while in my production site with no discernible pattern. I instrumented the code to know with page throws it and, boy, I look at every place of that template (and included ones) and can't see how this could happen.
What kind of error is this code fragment trying to prevent. Is it the aforementioned {eval}?
if (!isset($var)) {
$this->trigger_error("eval: missing 'var' parameter");
return;
}
function smarty_function_eval($params, &$this)
{
extract($params);
if (!isset($var)) {
$this->trigger_error("eval: missing 'var' parameter");
return;
}
if($var == '') {
return;
} |
|
Back to top |
|
messju Administrator
Joined: 16 Apr 2003 Posts: 3336 Location: Oldenburg, Germany
|
Posted: Fri Jul 25, 2003 9:48 am Post subject: |
|
|
isset() returns false on null-values.
{eval var=''} works but {eval var=null} throws the error you mention.
this means {eval var=$foo} also throws the error, if $foo was never set/assigned before.
does this help you tracking down your problem? |
|
Back to top |
|
ubaldo Smarty Regular
Joined: 21 Apr 2003 Posts: 35 Location: Barcelona, Spain
|
Posted: Fri Jul 25, 2003 12:26 pm Post subject: |
|
|
Well. I know about isset, naturally.
First, all my evals are in the form of {eval var="#aconfig var#"} and I checked the config files (for all my languages) I thoroughly researched this.
It's an intermittent preblem. Usually disappears after I clear the cache and the templates (but then I see them sporadically). This is a production site with moderate traffic.
My questions is whether the behaviour of eval isn't too extreme. Notice that smarty throws the same kind of error (U_USER_WARNING) in the case of a {config load of a non existent resource)
Can it just behave like eval of an empty variable (set to ""). that is, output nothing. Any side effects?
I suppose that the intention is a noble one, that is, to help debugging problems earlier.
I don't know if I'm making any sense. I'm just out of shape because, on top of it, I think that the missing or null variable reporting is bogus in my case. I'll keep digging.
Ubaldo
www.loquo.com |
|
Back to top |
|
messju Administrator
Joined: 16 Apr 2003 Posts: 3336 Location: Oldenburg, Germany
|
Posted: Fri Jul 25, 2003 12:48 pm Post subject: |
|
|
overall you are right. the error-message is bogus, of course. IMHO, the test should go:
[php:1:f3d389de44]
if (!in_array('var', array_keys($params))) {
$smarty->trigger_error("eval: missing 'var' parameter");
return;
}
if (empty($params['var'])) {
return;
}
...
[/php:1:f3d389de44] |
|
Back to top |
|
ubaldo Smarty Regular
Joined: 21 Apr 2003 Posts: 35 Location: Barcelona, Spain
|
Posted: Fri Jul 25, 2003 2:24 pm Post subject: |
|
|
I had already changed it along the lines of what you propossed because I needed to rush (it's a production site problem on a key page). Curiously almost identical code to what you've proposed.
I get the feeling that most people want to have this behaviour, that is, if var content is null or empty simply output nothing, only complain if var param isn't supplied. IMHO, I would make those changes in the 2.5.x code.
I'm back now to square one, now users presumably be able to see the page (no errror) but with a blank spot. This happens, again, once in a while. It might have to do with Turk mmcache (the accelerator that I'm using at the moment, who knows). This is the kind of problem that not even my worst enemies deserve to have, well, maybe so.
Thanks a lot for looking into my petty ailment.
Ubaldo
www.loquo.com |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|