-
Notifications
You must be signed in to change notification settings - Fork 714
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
isset() check fails within section $VAR[loop].key syntax if "key" or "loop" does not exist #453
Comments
@chrisknerr You may take a look at workaround introduced in #499 (comment) I hope this solves your issue too! |
Thank you very much! Your workaround does the trick in some cases like the ones you mentioned in your referenced comment and is a good solution for the moment I think! Unfortunately this seems not to work with all use cases (like checking or using a var from a loop directly like in my first example). So I still hope for an official fix to that especially because the old behaviour saves you from creating additional temporary vars with already existing content. I'm currently using some older compiler files for Smarty to work in production and just manually implemented the critical fixes that came from 3.1.30 to 3.1.33 and did some project specific additional blocks to the smarty files. For me this was currently the best option because I didn't need to change a lot of template syntax for that. :D |
Hello there!
I recently updated the Smarty library in a project from v3.1.30 to v3.1.32 and noticed, that this version seems to have a problem with the
isset()
check if a var is not set and I'm using the syntax you usually use to address something in a section with$VAR[counter].subvalue
. As soon I roll back to v3.1.30 the same template code works again so I think it must have to do something with a change made in 3.1.31 or 3.1.32. I'm using both with PHP7.2 and error_reporting is set to strict including all notices for uninitialized vars in my dev environment.Has the syntax just changed or does
[]
fail now due to a bug? (It worked on 3.1.30).I made an example for you here:
With Smarty v3.1.30 I see:
so this is the expected behaviour: The vars that are not existing in the section array fail the isset check, but the template gets compiled further to the end.
However on Smarty v3.1.32 I see:
In other words: As soon I have an isset with a non-existing array key the template stops to compile further and I end up just seeing a blank page. No message in the error log, no message when I turn on Smarty Debugging ... very mysterious.
The funny thing is when I write it like this{if isset($TOPICS.topics.thisdoesnotexist)}
it seems to work.Am I doing something wrong here or is that a bug? It makes me wonder that the syntax with
[]
does NOT fail if the value is really set and only fails when its not set, so if you got rid of the[]
variant and there is a different syntax for sections, shouldn't this fail with a syntax error in both cases then? Or shouldn't it behave like in 3.1.30 where using that worked correctly and nonexistant values didn't cause the template compiling to stop/fail?Thanks in advance!
The text was updated successfully, but these errors were encountered: