smarty icon indicating copy to clipboard operation
smarty copied to clipboard

Fix error handler allowUndefinedVars

Open rudiedirkx opened this issue 3 years ago • 1 comments

handleError only checks for property value, which is odd. I'm getting error

Attempt to read property "id" on null

Because id is the property being accessed. So it should check for any property name, not just value.

rudiedirkx avatar Feb 18 '22 22:02 rudiedirkx

This pull request would make it possible to migrate to newer version without a large amount of changes. Could this be merged?

Martijn-Bos avatar Aug 09 '22 10:08 Martijn-Bos

Does nobody have allowUndefinedVars enabled in PHP 8.0+?

rudiedirkx avatar Nov 22 '22 20:11 rudiedirkx

This change seems straightforward. Should be able to merge this. Just to be clear: could you provide an exact issue? I.e. what problem does this solve?

wisskid avatar Nov 22 '22 22:11 wisskid

$smarty->assign('object', null);
====
{{$object->name}}

That would trigger a

Attempt to read property "name" on null


I'll fix the merge conflict.

rudiedirkx avatar Nov 24 '22 10:11 rudiedirkx

I propose a slightly different implementation, see https://github.com/smarty-php/smarty/pull/832

wisskid avatar Nov 24 '22 17:11 wisskid