View previous topic :: View next topic |
Author |
Message |
legendarydrew Smarty Rookie
Joined: 04 Feb 2010 Posts: 5
|
Posted: Wed Feb 23, 2011 3:30 pm Post subject: Undefined variable error? |
|
|
I've just upgraded to the latest Smarty (3.0.7) with a fresh copy, and for some reason I get the following error when Smarty comes across a variable placeholder that hasn't been assigned:
Undefined variable: args_id ~ C:\...\sysplugins\smarty_internal_data.php [ 291 ]
I'm guessing it's just a thrown notice, but nothing happens after it. |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Wed Feb 23, 2011 3:43 pm Post subject: |
|
|
On undefinied variables Smarty3 does drop a notice unless you did not disabled notices with $smarty->error_reporting property.
Anyway it does continue execution. |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Wed Feb 23, 2011 5:54 pm Post subject: |
|
|
Quote: | NOTICE for 3.0.5 release:
Smarty now follows the PHP error_reporting level by default. If PHP does not mask E_NOTICE and you try to access an unset template variable, you will now get an E_NOTICE warning. To revert to the old behavior:
$smarty->error_reporting = E_ALL & ~E_NOTICE; |
|
|
Back to top |
|
MarkM Smarty Rookie
Joined: 06 Jun 2011 Posts: 5
|
Posted: Mon Jun 06, 2011 5:37 am Post subject: |
|
|
I am having the same problem using version 3.0.8. I set the following:
$smarty->error_reporting = E_ALL & ~E_NOTICE;
where $smarty is my smarty object. This is called before make any display calls. I am doing the other initialization items before it like setting the directories and registering plugins. I also do a few assignments. Does this need to be set before doing anything else?
This is a fragment of the message in my error log:
.../smarty/sysplugins/smarty_internal_data.php (291) Undefined variable: xxx .... |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Mon Jun 06, 2011 3:33 pm Post subject: |
|
|
Setting error_reporting befor you call display should be okay.
Do you have caching enabled? may be for some reasion the error messaged got stored in the cache file. Just in case empty the cache folder. |
|
Back to top |
|
MarkM Smarty Rookie
Joined: 06 Jun 2011 Posts: 5
|
Posted: Mon Jun 06, 2011 8:57 pm Post subject: |
|
|
I cleared the cache and the same problem is occurring. I am using the fpm version of php if that matters. These notices appear in my web server's error log. Here is a more detailed version of the notice message:
2011-06-06 1:51:42 pm /smarty/sysplugins/smarty_internal_data.php (291) Undefined variable: xxx" while reading response header from upstream, client: IP Address, server: URL, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "URL" {I obfuscated the variable name,IP Address and URL in this example} |
|
Back to top |
|
SOSkr Smarty n00b
Joined: 10 Sep 2011 Posts: 2
|
Posted: Sat Sep 10, 2011 2:50 pm Post subject: Problem |
|
|
i have the same problem, anyone could solve it? |
|
Back to top |
|
MarkM Smarty Rookie
Joined: 06 Jun 2011 Posts: 5
|
Posted: Sat Sep 10, 2011 6:06 pm Post subject: |
|
|
I should also mention that I have xdebug installed. I forgot to mention that in my initial post. I know that is does get involved with PHP's error/warning/notice system |
|
Back to top |
|
SOSkr Smarty n00b
Joined: 10 Sep 2011 Posts: 2
|
Posted: Sat Sep 10, 2011 6:34 pm Post subject: |
|
|
I've been testing one by one, the version of a smarty and I realized that even the version 3.0.5 this Code: | $smarty->error_reporting = E_ALL & ~E_NOTICE; | worked, from the version 3.0.6 does not work.
Checking the logs I could see this change Quote: | bugfix getTemplateVars() should return 'null' instead dropping E_NOTICE on an unassigned variable | in 3.0.6, I do not know what does, but maybe you can use to discover what is happening. |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Sun Sep 11, 2011 8:30 am Post subject: |
|
|
Are you using codeigniter? It does grab and log errors by it's own. Also xdebug or special PHP versions like fpm may effect error logging. |
|
Back to top |
|
cbj4074 Smarty Regular
Joined: 10 Nov 2011 Posts: 49
|
Posted: Thu Nov 10, 2011 4:58 pm Post subject: |
|
|
I have the same issue. When I upgraded to Smarty 3.0.8, this issue was introduced.
Like the others in this thread, I am configuring Smarty error reporting with the following:
Code: |
$smarty->error_reporting = E_ALL & ~E_NOTICE;
|
I am doing this before calling $smarty->fetch() or $smarty->display().
I've seen mention of xdebug and PHP FPM, but I am using neither on the server on which this is a problem.
Curiously, I am using xdebug locally, but the problem does not occur there (it only occurs on the production server).
This is a deal-breaker for us. It seems that this problem does not occur for most, but if this thread is any indication, the problem is widespread enough to warrant further investigation on behalf of the developers.
What can I do to help?
Thank you! |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Thu Nov 10, 2011 10:09 pm Post subject: |
|
|
Could it be that your server did configure error_reporting within httpd.conf by using php_admin_value?
I that case the server does not allow changing the error_reporting at script level.
Anyway it is better to handle expected undefinded variables in templates by using the default modifier or isset() conditions. |
|
Back to top |
|
cbj4074 Smarty Regular
Joined: 10 Nov 2011 Posts: 49
|
Posted: Thu Nov 10, 2011 11:04 pm Post subject: |
|
|
Thanks, U.Tews! You're absolutely right.
In the development environment in question, the error-reporting level is defined within the vhost's configuration file (using php_admin_value); this is to prevent developers from lowering the value and writing sloppy code as a result. It makes perfect sense that we would not be able to override that value at run-time. Again, thank you for the invaluable insight here.
Further, we'll take your advice and use the default modifier and isset() to achieve the desired result in a more sane manner.
Cheers! |
|
Back to top |
|
MarkM Smarty Rookie
Joined: 06 Jun 2011 Posts: 5
|
Posted: Thu Nov 10, 2011 11:07 pm Post subject: |
|
|
I am not using Apache but nginx and I am using xdebug with php-fpm fast cgi daemon.
I completely control the server with root access (not a shared virtual environment with a 3rd party that has ultimate control). I still have these issues. |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Fri Nov 11, 2011 12:15 am Post subject: |
|
|
Have a look at the Log_Level parameter in php-fpm.conf. |
|
Back to top |
|
|