Open yurii-sio2 opened 2 months ago
May somebody react to this problem, please?
This could be a problem. I opened #988 because I suspected that there might be a problem there. Will have to take a look at it.
There is a problem within Smarty compiler
{if isset($foo) } ..... {/if}
will be compiled (v5.4.1) into
<?php if ((null !== ($_smarty_tpl->getValue('foo') ?? null))) {?> ..... <?php }?>
but it should be
<?php if ((null !== ($_smarty_tpl->hasVariable('foo') ?? null))) {?> ..... <?php }?>
When trying to read from undefined/unassigned variable there is no warning triggered, because Smarty always converts any unassigned and null variables into an empty string.
These is the option $smarty->error_unassigned = true, it enables Warning about accessing an unassigned variable. But! This is not useful because it triggers Warning even when you check a variable with isset(...)
{if isset($variable)} - results in Warning when error_unassigned = true
IMO when checking a variable with isset() then it should not trigger a warning because you explicitly check for variable existence.
This is especially uncomfortable when you develop new big form and you don't know what variables you didn't pass yet.
Checked in Smarty version 5.3.1. Seems like current version also has this problem.