Skip to content
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

Warning should not be triggered when checking for isset() of unassigned variable and smarty->error_unassigned = true #1063

Open
yurii-sio2 opened this issue Sep 6, 2024 · 3 comments

Comments

@yurii-sio2
Copy link

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.

@yurii-sio2
Copy link
Author

May somebody react to this problem, please?

@wisskid
Copy link
Contributor

wisskid commented Oct 6, 2024

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.

@infira
Copy link

infira commented Oct 15, 2024

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 }?>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants