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

PHP8 and smarty create a lot of warnings #11212

Closed
annando opened this issue Feb 5, 2022 · 10 comments · Fixed by #11257
Closed

PHP8 and smarty create a lot of warnings #11212

annando opened this issue Feb 5, 2022 · 10 comments · Fixed by #11257
Assignees
Labels
Milestone

Comments

@annando
Copy link
Collaborator

annando commented Feb 5, 2022

I recently updated my server to PHP8. Friendica seems to work with it now - with the exception that smarty is generating a lot of warnings:

PHP Warning:  Undefined array key "name" in view/smarty3/compiled/810e28937977578ebd6d23086910568b640eade6_2.file.event_stream_item.tpl.php on line 59

That line looks this way:

<?php if ($_smarty_tpl->tpl_vars['location']->value['name']) {?>

In the template it looks that way:

{{if $location.name}}

There is a way fixing it: We can replace that check with a call like this:

{{if array_key_exists('name', $location)}}

But since we are using these types of checks all the time this would mean a lot of work in the templates.

Question is if there is some shortcut. Is there some smarty update or some smarty option that can help?

@annando annando added the Bug label Feb 5, 2022
@MrPetovan
Copy link
Collaborator

We need to upgrade to Smarty version 4 that was released last November, and call $smarty->muteUndefinedOrNullWarnings(); when we instantiate it.

@MrPetovan MrPetovan self-assigned this Feb 19, 2022
@MrPetovan MrPetovan added this to the 2022.05 milestone Feb 19, 2022
@annando
Copy link
Collaborator Author

annando commented Feb 19, 2022

I'm still receiving these warnings:

[19-Feb-2022 14:22:37 UTC] PHP Warning:  Trying to access array offset on value of type bool in /htdocs/view/smarty3/compiled/533afe24beaad83b166e60561a10571d8bd76f73_2.file.wall_thread.tpl.php on line 500
[19-Feb-2022 14:22:37 UTC] PHP Warning:  Trying to access array offset on value of type bool in /htdocs/view/smarty3/compiled/533afe24beaad83b166e60561a10571d8bd76f73_2.file.wall_thread.tpl.php on line 672
[19-Feb-2022 14:22:37 UTC] PHP Warning:  Trying to access array offset on value of type bool in /htdocs/view/smarty3/compiled/533afe24beaad83b166e60561a10571d8bd76f73_2.file.wall_thread.tpl.php on line 792
[19-Feb-2022 14:22:37 UTC] PHP Warning:  Trying to access array offset on value of type bool in /htdocs/view/smarty3/compiled/533afe24beaad83b166e60561a10571d8bd76f73_2.file.wall_thread.tpl.php on line 912

@annando annando reopened this Feb 19, 2022
@MrPetovan
Copy link
Collaborator

Please clear your Smarty cache, these templates were likely created with the previous version of Smarty. The cache is only refresh when the source file changes, which isn't the case when we just upgrade Smarty.

@nupplaphil
Copy link
Collaborator

@MrPetovan we could wipe the cache during an update process to avoid this situstion, couldn't we?

@MrPetovan
Copy link
Collaborator

Yes we could, although we could do it as a one-off each time we're upgrading Smarty since we rarely do it.

@annando
Copy link
Collaborator Author

annando commented Feb 19, 2022

I cleared the cache but the warning reappeared.

@nupplaphil
Copy link
Collaborator

Yes we could, although we could do it as a one-off each time we're upgrading Smarty since we rarely do it.

Yes I ment exactly that case , just one time after a smarty upgrade, not every time :)

@MrPetovan
Copy link
Collaborator

I cleared the cache but the warning reappeared.

Ugh, I did what I was told to do, not sure what to do next since I don't have PHP8 to test.

@annando
Copy link
Collaborator Author

annando commented Feb 19, 2022

It is only these three warnings. They occur with multi level arrays. One of the occurrences is {{if $item.drop.dropping}} which I changed to {{if $item.drop && $item.drop.dropping}} to reduce the noise. I'm not sure if we can fix this at the engine level or if we should fix that at the template level.

@tobiasd tobiasd modified the milestones: 2022.03, 2022.05 Feb 28, 2022
@annando
Copy link
Collaborator Author

annando commented Mar 21, 2022

This is fixed now.

@annando annando closed this as completed Mar 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants