Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

smarty 3.1 & error_reporting

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Bugs
View previous topic :: View next topic  
Author Message
maind
Smarty Rookie


Joined: 14 Dec 2011
Posts: 7

PostPosted: Wed Dec 14, 2011 9:07 am    Post subject: smarty 3.1 & error_reporting Reply with quote

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
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 5068
Location: Hamburg / Germany

PostPosted: Wed Dec 14, 2011 4:03 pm    Post subject: Reply with quote

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
View user's profile Send private message
maind
Smarty Rookie


Joined: 14 Dec 2011
Posts: 7

PostPosted: Wed Dec 14, 2011 8:34 pm    Post subject: Reply with quote

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
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 5068
Location: Hamburg / Germany

PostPosted: Wed Dec 14, 2011 10:40 pm    Post subject: Reply with quote

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
View user's profile Send private message
maind
Smarty Rookie


Joined: 14 Dec 2011
Posts: 7

PostPosted: Thu Dec 15, 2011 10:47 am    Post subject: Reply with quote

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
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 5068
Location: Hamburg / Germany

PostPosted: Fri Dec 16, 2011 3:43 pm    Post subject: Reply with quote

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
View user's profile Send private message
maind
Smarty Rookie


Joined: 14 Dec 2011
Posts: 7

PostPosted: Sat Dec 17, 2011 7:32 am    Post subject: Reply with quote

Got it, thanks.
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Bugs All times are GMT
Page 1 of 1

 
Jump to:  
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
Protected by Anti-Spam ACP