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.