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

constant resolving to string without raising notice

 
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
williamorazi
Smarty n00b


Joined: 16 Mar 2015
Posts: 1
Location: Baltimore, MD

PostPosted: Mon Mar 16, 2015 8:24 pm    Post subject: constant resolving to string without raising notice Reply with quote

Assume you have the following logic in a template file, where "MY_CONSTANT" would be a boolean value.

Code:
{if $smarty.const.MY_CONSTANT} ... {/if}


This bug arises when the constant is not defined. Looking through the compiled template, I'm seeing something along the following lines:

Code:
<?php if (@MY_CONSTANT): ?>


The problem is that PHP is silently converting this to a string and raising a notice. Since Smarty is suppressing this error via the use of "@" above, the developer will not see this notice. Therefore, the condition above is ALWAYS evaluating to TRUE and the developer will never see any information to the contrary.

My suggestion would be that when compiling the HTML, a validation check is performed to ensure that the constant is defined (and an appropriate notice is raised). Otherwise, the error suppression should be removed so that the notice is able to be received.
Back to top
View user's profile Send private message Yahoo Messenger
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