smarty-php / smarty

Smarty is a template engine for PHP, facilitating the separation of presentation (HTML/CSS) from application logic.
Other
2.24k stars 705 forks source link

Undefined array keys warnings. #924

Closed jackie-t closed 3 months ago

jackie-t commented 8 months ago

Hey guys,

Just a quick question, because I updated to PHP 8 and had "undefined array key" warnings all over the place. I didn't see anything in the notes, so I checked the Smarty code, and I found there is a muteUndefinedOrNullWarnings() that I can call. It says it's for "PHP7 compatibility mode", but I guess it's also needed for PHP8? PHP7 is EOL now anyway.

While I can do that, and it removes the warnings, this is hacky as all hell. Instead of doing isset() using this function installs a custom error handler, that preg_matches the error messages and ignores them, if they look like the messages above.

Am I doing something wrong? Where is this project headed, anyway? I mean, I'm not too involved into the code, so I wouldn't know where in the template generation the isset needs to go, but is this even worth investing time anymore? The smarty website has casino spam all over its front page, the code feels like an old shed held together by duct tape lol so it just kind of but barely performs still.

barisyazganc commented 7 months ago

Hi,

I have the same problem,

muteUndefinedOrNullWarnings() works great for php version below 8.3, i accidently updated to 8.3 and it doesnt work anymore because even it works internally for smarty, php throws warnings unless i set display_errors to 0

any idea?

wisskid commented 7 months ago

Hi,

I have the same problem,

muteUndefinedOrNullWarnings() works great for php version below 8.3, i accidently updated to 8.3 and it doesnt work anymore because even it works internally for smarty, php throws warnings unless i set display_errors to 0

any idea?

Should have been fixed in latest 4.3 release!