Page 1 of 1

Quick PHP 8 fix for MenuManager please!

Posted: Sat Oct 01, 2022 10:43 pm
by Charles Butcher
I would be very grateful if someone could tell me how to patch the MenuManager module to work with PHP 8. The "each" at line 111:

Code: Select all

while (list($key) = each($children)) {
breaks the site. I tried:

Code: Select all

foreach( $children as $key ) {
without success. I know I should probably be using Navigator instead, but I'm not a developer and until I can get my head round that I'd like to keep it working with MenuManager and PHP 8 if possible.

Any hints appreciated.

Re: Quick PHP 8 fix for MenuManager please!

Posted: Sat Oct 01, 2022 11:55 pm
by MantaPro
Try

Code: Select all

 foreach ($children as $key => $value)
In the old code the each returns the key & value pairs. The list assigns the key but ignores the value.

In your attempted code you were looping through the children and assigning the value to a field called key. Whereas you want the field called key to hold the key.

Good luck

Re: Quick PHP 8 fix for MenuManager please!

Posted: Sun Oct 02, 2022 9:02 am
by Charles Butcher
Thank you very much indeed! That works. Now the errors have moved to old modules like CGGoogleMaps – but it's progress :-)

Re: Quick PHP 8 fix for MenuManager please!

Posted: Mon Oct 03, 2022 12:59 am
by DIGI3
Just a reminder that source code changes are not permitted on the forum (there's pinned posts outlining the reasoning so I won't get into it here). Also keep in mind MenuManager was deprecated years ago, and will stop being included very soon. Migrating to Navigator is the best option.

Re: Quick PHP 8 fix for MenuManager please!

Posted: Mon Oct 03, 2022 10:43 am
by Charles Butcher
Thanks DIGI3, and apologies for breaking that rule – which makes perfect sense. I'll get to grips with Navigator. I inherited the original MenuManager template in 2009 as part of a complete site design, so I have never needed to understand it. This will be a useful learning experience.

Re: Quick PHP 8 fix for MenuManager please!

Posted: Thu Mar 06, 2025 8:30 am
by ohaldi
foreach ($children as $key => $value)

I also have this problem now. I changed this line 111 to the above line.
But now I have one error at line :
Parse error: syntax error, unexpected token "return", expecting "function" or "const" in /home/httpd/vhosts/haldi.ch/httpdocs/cms/modules/MenuManager/MenuManager.module.php on line 181

Could somebody send me this MenuManager php file?
Regards

Re: Quick PHP 8 fix for MenuManager please!

Posted: Thu Mar 06, 2025 12:39 pm
by Charles Butcher
I've sent you a PM. But I am puzzled how you were able to patch line 111 if you don't have access to MenuManager.module.php – this new error is just line 181 in the same file. Good luck in fixing it. DIGI3 did a wonderful job on upgrading my own site so that I no longer need to use MenuManager.

Re: Quick PHP 8 fix for MenuManager please!

Posted: Tue Mar 11, 2025 7:07 am
by ohaldi
I made too many mistakes with CMSMS.
I deleted the MenuManager module before changing anything. It was a big mistake.
Now I have problems everywhere. Also, the content manager template shows **ERROR**.
The CMS management still work well.
I'm going to ask my supplier to restore a backup from last month. If that's not possible. Then I'll probably look for another CMS.
Which is strange with the PHP 8.3 update from the host. A few months ago, I was already using PHP 8 and everything was working fine.
Thanks again for all your help.

Re: Quick PHP 8 fix for MenuManager please!

Posted: Tue Mar 11, 2025 11:09 am
by jce76350
@ ohaldi see may answer on the FR forum ;)