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

Administrator Menu Editor Unusable in Gantry 5.5.15 with PHP 8.1.13 #3103

Open
bascherz opened this issue Dec 18, 2022 · 8 comments
Open

Administrator Menu Editor Unusable in Gantry 5.5.15 with PHP 8.1.13 #3103

bascherz opened this issue Dec 18, 2022 · 8 comments

Comments

@bascherz
Copy link

bascherz commented Dec 18, 2022

This issue was previously mentioned in #3073. I was asked to enter a new issue focusing specifically on this problem.

As of updating to 5.5.15, which resolved this problem (#3088), the Menu Editor is no longer usable. This is what I get on all my sites running 5.5.15 (both Hydrogen and Helium templates) for all menus. This has been occurring with Joomla! 4.2.5 and 4.2.6 since updating to PHP 8.1.13 and Gantry 5.5.15.

image

@iantrudell
Copy link

Same issue here, says invalid menu structure

@N8Solutions
Copy link

@bascherz what version of PHP are you using when this error happens?

@iantrudell
Copy link

@bascherz what version of PHP are you using when this error happens?

PHP 8.1.12

@bascherz
Copy link
Author

bascherz commented Dec 19, 2022

@iantrudell You know, I didn't think about it when I posted, since earlier I had posted that I needed to update to Gantry 5.5.15 to fix a front end fatal error issue (#3088) with PHP 8.1. So it's quite likely it's got something to do with that. I had been running PHP 7.3 and got tired of J!4 complaining about it. Gantry 5.5.15 did resolve that problem, so I am now on PHP 8.1.13. It is since then that I noticed this issue.

By the way, I tried backing up to PHP 8.0 yesterday and got a different front end fatal error with Gantry.

@bascherz bascherz changed the title Administrator Menu Editor Unusable in Gantry 5.5.15 Administrator Menu Editor Unusable in Gantry 5.5.15 with PHP 8.1.13 Dec 19, 2022
@iantrudell
Copy link

I dug a little deeper into this and I have a few fixes:

In libraries\gantry5\src\classes\Gantry\Admin\Controller\Html\Menu.php
On line 573, replace this:

$items = json_decode($items, true);

with this:

$items = json_decode((string)$items, true);

In libraries\gantry5\vendor\twig\twig\src\Extension\CoreExtension.php
On line 521, replace this:

return strtr($str, $from, $to);

with this:

return strtr((string)$str, $from, $to);

On line 528, replace this:

return strtr($str, twig_to_array($from));

with this:

return strtr((string)$str, twig_to_array($from));

On line 996, replace this:

return trim($string, $characterMask);

with this:

return trim((string)$string, $characterMask);

On line 998, replace this:

return ltrim($string, $characterMask);

with this:

return ltrim((string)$string, $characterMask);

On line 1000, replace this:

return rtrim($string, $characterMask);

with this:

return rtrim((string)$string, $characterMask);

In libraries\gantry5\compat\vendor\twig\twig\src\Extension\CoreExtension.php
On line 527, replace this:

return strtr($str, $from, $to);

with this:

return strtr((string)$str, $from, $to);

On line 534, replace this:

return strtr($str, twig_to_array($from));

with this:

return strtr((string)$str, twig_to_array($from));

On line 990, replace this:

return trim($string, $characterMask);

with this:

return trim((string)$string, $characterMask);

On line 992, replace this:

return ltrim($string, $characterMask);

with this:

return ltrim((string)$string, $characterMask);

On line 994, replace this:

return rtrim($string, $characterMask);

with this:

return rtrim((string)$string, $characterMask);

This forces null string variables to be empty strings (since you are no longer allowed to pass in null to strtr in PHP 8.1).

This should also make the Menu Editor usable again (you may have to add the #[\ReturnTypeWillChange] annotations to various Pimple and Twig files too to get the warnings to disappear).

@bascherz
Copy link
Author

@iantrudell, those changes do seem to fix the issue. Any idea how long it might be for an official fix to appear?

Thanks, bud!

@joseOlivares
Copy link

I have the same issue.

@N8Solutions
Copy link

I have the same issue.

@joseOlivares You should download the latest release 5.5.16.

You can find the latest releases here:
https://github.com/gantry/gantry5/releases

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

4 participants