View previous topic :: View next topic |
Author |
Message |
maind Smarty Rookie
Joined: 14 Dec 2011 Posts: 7
|
Posted: Wed Dec 14, 2011 9:07 am Post subject: smarty 3.1 & error_reporting |
|
|
Hello!
I've successfully updated to smarty 3.1.*.
But saw, that by using the same error_reporting level as before (E_ALL | E_STRICT),
I do *not* see an old notices as in earlier versions.
F.e.:
write in template something like
{#unexisting_config_variable#}
expected:
notice about using undefined config variable as it was in smarty 3.0.*
results:
no notice - just an empty string. |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Wed Dec 14, 2011 4:03 pm Post subject: |
|
|
I can't confirm a bug.
Are you sure that you did not assign to $smarty->error_reporting a level which did exclude E_NOTICE?? |
|
Back to top |
|
maind Smarty Rookie
Joined: 14 Dec 2011 Posts: 7
|
Posted: Wed Dec 14, 2011 8:34 pm Post subject: |
|
|
Absolutely sure. Now tested it even on smarty 3.1.6 demo and got the same problem.
Steps to reproduce:
1) download the latest version of smarty (3.1.6) - http://www.smarty.net/download
2) edit Smarty-3.1.6/demo/index.php in such way:
<?php
require('../libs/Smarty.class.php');
$smarty = new Smarty;
$smarty->error_reporting = E_ALL | E_STRICT;
$smarty->display('index.tpl');
3) edit Smarty-3.1.6/demo/templates/index.tpl in such way:
{#this_config_variable_is_not_exists#}
expected:
- notice about using of an undefined config variable
results:
- nothing. just an empty string. |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Wed Dec 14, 2011 10:40 pm Post subject: |
|
|
You must set
$smarty->error_unassigned = true; to enable notices.
This is the case since 3.1. For some reasion it was not documented and I was surprised myself finding it out now...
So we will update documentation and release notes. |
|
Back to top |
|
maind Smarty Rookie
Joined: 14 Dec 2011 Posts: 7
|
Posted: Thu Dec 15, 2011 10:47 am Post subject: |
|
|
Yes, it helps. But, as for me, that property works really strange now.
As I get from Smarty.class.php:
/**
* display error on not assigned variables
* @var boolean
*/
public $error_unassigned = false;
But, even in my example, if you edit Smarty-3.1.6/demo/templates/index.tpl in such way:
{#this_config_variable_is_not_exists#}
{$unexisting_variable}
Both variables are unassigned. And "error_unassigned" property is set to false.
But you'll actually *have* notice according to the usage of unassigned smarty variable ($unexisting_variable) and *no notice* according to the usage of unassigned smarty *config* variable.
Not actually fair I guess. |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Fri Dec 16, 2011 3:43 pm Post subject: |
|
|
The handling of unassigned variables has always been a topic.
I agree that it got in Smarty3 a bit inconsistant. The reasdion is that in Smarty 3.0 we used internally funtions to obtain both template and config variables. In these function we could check the error_unassigned status and drop a notice or not.
For speed optimizations in Smarty 3.1 this function is no longer used for obtaining template variables and PHP will drop a notice independend of the error_unassigned status. For consitency you could set error_unassiged = true and enable E_NOTICE in the $smarty->error_reporting.
We are currently working on Smarty 3.2 where a completely new approch for handling unassigned varibales is implement to get rid of all this problems.
So we have to live with the current situation at 3.1 because it cant be easily changed. |
|
Back to top |
|
maind Smarty Rookie
Joined: 14 Dec 2011 Posts: 7
|
Posted: Sat Dec 17, 2011 7:32 am Post subject: |
|
|
Got it, thanks. |
|
Back to top |
|
|