Menu Item Manager Empty in Joomla?

While working on one of our clients’ website (her version of Joomla was 1.5.14, but we think that this problem applies to all 1.5.x versions where x is less than 20), we noticed that the Menu Item Manager in Joomla’s backend had 0 men items, although the menu items existed as they were appearing on the website. This means that there is a (most likely) PHP script error that is causing the menu items not to appear on this page. So, what we did was that we turned on Error Reporting on the Global Configuration page to see whether the page had any (hidden) PHP errors.

Sure enough, when we turned on error reporting, we went back to the Menu Item Manager page and we saw the following errors:

Warning: Parameter 4 to JHTMLMenu::treerecurse() expected to be a reference, value given in /ourclientjoomalwebsite/libraries/joomla/html/html.php on line 87
Warning: array_slice() expects parameter 1 to be array, null given in /ourclientjoomalwebsite/administrator/components/com_menus/models/list.php on line 143
Warning: Invalid argument supplied for foreach() in /ourclientjoomalwebsite/administrator/components/com_menus/models/list.php on line 147
Warning: Invalid argument supplied for foreach() in /ourclientjoomalwebsite/administrator/components/com_menus/views/list/view.php on line 65
Warning: Invalid argument supplied for foreach() in /ourclientjoomalwebsite/administrator/components/com_menus/views/list/tmpl/default.php on line 69

As programmers, we know that usually the first problem is the cause of the rest of the problems, so, fixing the first problem may fix the other problems as well. That’s why we went to the file html.php which is located under the /ourclientjoomalwebsite/libraries/joomla/html/ directory. Here’s the code that we found at line 87:

return call_user_func_array( array( $className, $func ), $args );

Obviously, the function expects the second parameter to be passed by reference, and since we don’t care about the $args parameter after the function gets executed, we can safely pass it by reference to fix the problem (passing by reference means that any alterations to the parameter in the function are permanent, for example, if inside the function we set $args to NULL, then $args will be changed to NULL even when the function is finished executing). So, in order to fix the first problem, we changed the above code to the below:

return call_user_func_array( array( $className, $func ), &$args );

(Notice the & before $args.)

Surprise, surprise! After uploading the html.php file with the above change, everything started working again. The menu items appeared and we don’t see any other error on this page.

But why was the Menu Item Manager empty in the first place?

Usually this happens because of a PHP upgrade done on your server (most likely by your hosting company). Usually PHP/MySQL updates to your server can mean trouble to your Joomla website. Such updates, especially if your Joomla website is very old, can make your website fully dysfunctional.

If you have problems doing the above, or if you don’t have the necessary programming expertise to do so, then fear not, we’re here to help. Just contact us and we’ll do the work for you in no time. We’ll only charge you an hour for doing the above (see our reasonable fees) and we’ll also check if you have other problems on your website resulting from the PHP upgrade.

Note added on 1:50 PM 17/03/2014 EST: Newer versions of PHP will no longer accept this solution, and will throw the following error: “Fatal error: Call-time pass-by-reference has been removed”. If you get this error, then you will need to fix the calling function rather than the function call (we know – it’s confusing). In short, you will need to open the file menu.php, which is located under the /libraries/joomla/html/html folder, and change this line:

function treerecurse( $id, $indent, $list, &$children, $maxlevel=9999, $level=0, $type=1 )

to:

function treerecurse( $id, $indent, $list, $children, $maxlevel=9999, $level=0, $type=1 )

Behold the missing ampersand in the solution. This should fix the problem. Note that you should not apply this fix in conjunction with the fix described above, or else it will not work.

16 Responses to “Menu Item Manager Empty in Joomla?”
  1. Comment by richard — May 28, 2012 @ 7:33 am

    Guys. Thanks for this – absolutely saved me hours of noodling and far more helpful than trying to find a fox for this on the Joomla forums. Kudos.

  2. Comment by Arief Jauhari — June 18, 2012 @ 1:20 am

    From Indonesia with so many thanks to you. It works amazingly and solved a lot of problems in my back end website. Just with one character ‘&’ and all are fixed. Thank you!

  3. Comment by diginugis — September 5, 2012 @ 5:56 am

    I got my menus back on the frontend but my backend still doesn’t show that menu!

  4. Comment by Mark Hensberg — September 6, 2012 @ 5:49 am

    Unbelievable !!!!!!

    After days of reading books, watching Videos and Google, I finally came across your article……absolutely brilliant !

    I’m no IT guru or Joomla guru, but your instructions were perfectly clear and it works like a charm.

    Thank You so Much !

  5. Comment by Peter McPhillips — September 14, 2012 @ 4:54 am

    a magic bullet – saved hours of hassle

  6. Comment by John — January 3, 2013 @ 6:03 pm

    Hi,

    I applied the above. It apparently solved the displayed warnings in the “Menu administration” page. The menu structure is gone. But nothing changed on the front-end.

    Do you have any suggestions ?

  7. Comment by Fadi — January 4, 2013 @ 3:00 am

    Hi John,

    Try enabling the error reporting and see if you see another error on the frontend.

  8. Comment by Valentijn — February 22, 2013 @ 2:18 am

    Spot on! Thanks very much, our hosting company switched server and problems arose. Solved! Got the menu items back. Thanks again

  9. Comment by Nicole — February 28, 2013 @ 6:22 am

    Thank you very much for this. Very helpful and easy to fix following your write-up!

  10. Comment by Joe — May 16, 2013 @ 10:10 am

    great – i fixed now the issue with Joomla 1.5.6 in frontend (deleting an &) and in backend (adding an &) :-) very very nice! you saved my weekend :)

  11. Comment by Craig — August 11, 2013 @ 10:12 am

    Using 1.5.8

    after doing this “Menu Item Manager” now list everything and can edit, which is major progress!

    but …

    Extensions > Module Manager > click to edit module

    Still just gives an empty or blank browser window.

    and no menu items show on my website – it hasn’t been working for years and I imagine it’s because of my ISP installing a newer version of MySQL, which is

    MySQL client version: 5.0.51a

    phpMyAdmin – 2.11.11.2

    Thank you!

    Craig

  12. Comment by Fadi — August 12, 2013 @ 10:36 am

    Hi Craig,

    Please try enabling error reporting (see: http://www.itoctopus.com/error-reporting-in-joomla ) to know what the error is. Alternatively, we can fix the problem for you ourselves – all you need is to contact us.

  13. Comment by James — August 21, 2014 @ 6:31 am

    I did that perfectly worked fine and saved me after two weeks of losing my hair….

    Thank you very much!!!
    James

  14. Comment by Maksim — November 30, 2014 @ 8:24 am

    Thanks guys! This really works. Works like a charm now.

  15. Comment by Alex P — April 1, 2015 @ 8:35 am

    It works! Many thanks!

  16. Comment by Gretel — October 27, 2015 @ 9:00 am

    Thank you so much for this – helped out another joom tragic. although I created a new site on the latest platform, I still wanted to keep a copy of the old/working site. This helped heaps!

Leave a comment