|
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 |
williamorazi Smarty n00b
Joined: 16 Mar 2015 Posts: 1 Location: Baltimore, MD
|
Posted: Mon Mar 16, 2015 8:24 pm Post subject: constant resolving to string without raising notice |
|
|
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 |
|
|
|
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
|