smarty icon indicating copy to clipboard operation
smarty copied to clipboard

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

Open yurii-sio2 opened this issue 5 months ago • 3 comments

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 avatar Sep 06 '24 11:09 yurii-sio2