No Code Attached Yet bug
avatar brianteeman
brianteeman
11 Aug 2025

Steps to reproduce the issue

Enable debug (so that you will get the bug stack trace)
In the admin create a new admin menu - no need to create any items
Click on add module and publish the module in the menu position
Click on any item in the menu

Expected result

menu item opens

Actual result

Image

Error:
Call to a member function load() on false

  at D:\repos\j6\administrator\modules\mod_menu\src\Menu\CssMenu.php:236
  at Joomla\Module\Menu\Administrator\Menu\CssMenu->check(object(AdministratorMenuItem), object(Registry))
     (D:\repos\j6\administrator\modules\mod_menu\src\Menu\CssMenu.php:128)
  at Joomla\Module\Menu\Administrator\Menu\CssMenu->load(object(Registry), true)
     (D:\repos\j6\administrator\modules\mod_menu\src\Dispatcher\Dispatcher.php:41)
  at Joomla\Module\Menu\Administrator\Dispatcher\Dispatcher->getLayoutData()
     (D:\repos\j6\libraries\src\Dispatcher\AbstractModuleDispatcher.php:63)
  at Joomla\CMS\Dispatcher\AbstractModuleDispatcher->dispatch()
     (D:\repos\j6\libraries\src\Helper\ModuleHelper.php:289)
  at Joomla\CMS\Helper\ModuleHelper::renderRawModule(object(stdClass), object(Registry), array('name' => 'menu', 'style' => 'none'))
     (D:\repos\j6\libraries\src\Helper\ModuleHelper.php:160)
  at Joomla\CMS\Helper\ModuleHelper::renderModule(object(stdClass), array('name' => 'menu', 'style' => 'none'))
     (D:\repos\j6\libraries\src\Document\Renderer\Html\ModuleRenderer.php:99)
  at Joomla\CMS\Document\Renderer\Html\ModuleRenderer->render(object(stdClass), array('name' => 'menu', 'style' => 'none'), null)
     (D:\repos\j6\libraries\src\Document\Renderer\Html\ModulesRenderer.php:51)
  at Joomla\CMS\Document\Renderer\Html\ModulesRenderer->render('menu', array('name' => 'menu', 'style' => 'none'), null)
     (D:\repos\j6\libraries\src\Document\HtmlDocument.php:575)
  at Joomla\CMS\Document\HtmlDocument->getBuffer('modules', 'menu', array('name' => 'menu', 'style' => 'none'))
     (D:\repos\j6\libraries\src\Document\HtmlDocument.php:894)
  at Joomla\CMS\Document\HtmlDocument->_renderTemplate()
     (D:\repos\j6\libraries\src\Document\HtmlDocument.php:647)
  at Joomla\CMS\Document\HtmlDocument->render(false, array('template' => 'atum', 'directory' => 'D:\\repos\\j6\\administrator\\templates', 'debug' => true, 'csp_nonce' => null, 'templateInherits' => '', 'params' => object(Registry), 'file' => 'error.php'))
     (D:\repos\j6\libraries\src\Document\ErrorDocument.php:139)
  at Joomla\CMS\Document\ErrorDocument->render(false, array('template' => 'atum', 'directory' => 'D:\\repos\\j6\\administrator\\templates', 'debug' => true, 'csp_nonce' => null, 'templateInherits' => '', 'params' => object(Registry), 'file' => 'error.php'))
     (D:\repos\j6\libraries\src\Error\Renderer\HtmlRenderer.php:70)
  at Joomla\CMS\Error\Renderer\HtmlRenderer->render(object(Error))
     (D:\repos\j6\libraries\src\Exception\ExceptionHandler.php:136)
  at Joomla\CMS\Exception\ExceptionHandler::render(object(Error))
     (D:\repos\j6\libraries\src\Exception\ExceptionHandler.php:73)
  at Joomla\CMS\Exception\ExceptionHandler::handleException(object(Error))
     (D:\repos\j6\libraries\src\Application\CMSApplication.php:334)
  at Joomla\CMS\Application\CMSApplication->execute()
     (D:\repos\j6\administrator\includes\app.php:58)
  at require_once('D:\\repos\\j6\\administrator\\includes\\app.php')
     (D:\repos\j6\administrator\index.php:32)          

System information (as much as possible)

Additional comments

avatar brianteeman brianteeman - open - 11 Aug 2025
avatar joomla-cms-bot joomla-cms-bot - change - 11 Aug 2025
Labels Added: No Code Attached Yet
avatar joomla-cms-bot joomla-cms-bot - labeled - 11 Aug 2025
avatar richard67
richard67 - comment - 11 Aug 2025

Line 233 was changed with this PR #45687 from
$table = Table::getInstance('MenuType')
to
$table = $this->application->bootComponent('com_menu')->getMVCFactory()->createTable('MenuType').

Can it be that createTable doesn't work for tables located in the libraries/src/Table folder, so for these we have to stick with the deprecated Table::getInstance?

avatar brianteeman brianteeman - change - 11 Aug 2025
Title
[6.0] Fatal Error with admin menu module
[5.4][6.0] Fatal Error with admin menu module
avatar brianteeman brianteeman - edited - 11 Aug 2025
avatar brianteeman
brianteeman - comment - 11 Aug 2025

Confirming that the same fatal error occurs in 5.4

avatar richard67
richard67 - comment - 11 Aug 2025

@brianteeman Does it help if you revert the change in the administrator/modules/mod_menu/src/Menu/CssMenu.php file here https://github.com/joomla/joomla-cms/pull/45687/files#diff-27c98aa110e4d0bce12440e8d505d0ed75e87ac2e3660d6909fa68efd3c379ba ?

I.e. add back the use Joomla\CMS\Table\Table; at line 19 and change the $this->application->bootComponent('com_menu')->getMVCFactory()->createTable('MenuType') back to Table::getInstance('MenuType') in line 233 (or 234 after adding back the use statement)?

avatar LadySolveig
LadySolveig - comment - 12 Aug 2025

Not tested, but we could also try.

$this->application->bootComponent('com_menu')->getMVCFactory()->createTable('MenuType', 'Administrator');

I think the “Administrator” part might be missing here?
https://github.com/joomla/joomla-cms/pull/45687/files#diff-27c98aa110e4d0bce12440e8d505d0ed75e87ac2e3660d6909fa68efd3c379ba

And I think @richard67 is right, with re-adding the use statement for Joomla\CMS\Table\Table.

avatar brianteeman
brianteeman - comment - 12 Aug 2025

tried both suggestions without success

avatar brianteeman
brianteeman - comment - 12 Aug 2025

This works but then its still using deprecated code

adding
use Joomla\CMS\Table\Table

and changing $this->application->bootComponent('com_menu')->getMVCFactory()->createTable('MenuType') to $table = Table::getInstance('MenuType', 'Joomla\\CMS\\Table\\');

avatar richard67
richard67 - comment - 12 Aug 2025

Yes, I know, it's deprecated code. I only have a vague memory that there was something with it regarding these tables which are not located in administrator or site components but in libraries.

Checking our code I still see a lot of Table::getInstance usage.

avatar richard67 richard67 - change - 12 Aug 2025
Labels Added: Release Blocker bug
avatar richard67 richard67 - labeled - 12 Aug 2025
avatar richard67 richard67 - labeled - 12 Aug 2025
avatar LadySolveig
LadySolveig - comment - 12 Aug 2025

Does perhaps use \Joomla\CMS\Table\MenuType work?

I use this code snippet in one of my cli plugins and it is working fine.
At the moment, I can't think of any reason why this wouldn't work in this case, purely in theory.
If I can use it to bind and store it should also possible to load from the table.
I must be overlooking something that makes a difference.

        /** @var \Joomla\CMS\Table\MenuType $table */
        $table = $this->getApplication()->bootComponent('com_menus')->getMVCFactory()->createTable('MenuType', 'Administrator');

        $data = [
            'id'          => 0,
            'menutype'    => 'mainmenu-' . strtolower($langCode),
            'title'       => 'Main Menu (' . $langCode . ')',
            'description' => '',
        ];
        if (!$table->bind($data) || !$table->check() || !$table->store()) {
            return false;
        }
avatar HLeithner
HLeithner - comment - 12 Aug 2025

use $table = new \Joomla\CMS\Table\MenuType($db)

The issue here is that the $db object is not injected as far as I see, that means for testing brian could use it from the container for the person creating a pull request the db needs also be loaded from the container but in the getLayoutData method, actually it should be done in the dispatcher but didn't checked how it is working.

avatar richard67
richard67 - comment - 12 Aug 2025

@HLeithner And how would the getLayoutData pass the $db object to the CssMenu?

avatar HLeithner
HLeithner - comment - 12 Aug 2025

as written from the container

avatar HLeithner
HLeithner - comment - 12 Aug 2025

But I also said it should be done in the dispatcher but didn't looked at it yet.

avatar richard67
richard67 - comment - 12 Aug 2025

Yes, but if I do that in the getLayoutData, do I pass it then to the contructor of the CssMenu class as a new parameter?

avatar richard67
richard67 - comment - 12 Aug 2025

In the dispatcher it is not done yet. I would have to add a Factory::getContainer()->get(DatabaseInterface::class) (and of course a use statement for that interface).

avatar HLeithner
HLeithner - comment - 12 Aug 2025

yes of course, it needs to be available in the CssMenu thru the constructor or (maybe better) a DatabaseAwareInterface and trait and set afterwards. or both

avatar brianteeman
brianteeman - comment - 12 Aug 2025

I will leave it to you guys to come up with a solution. I'm afraid I'm not familiar enough with this new container code to help

avatar richard67
richard67 - comment - 12 Aug 2025

yes of course, it needs to be available in the CssMenu thru the constructor or (maybe better) a DatabaseAwareInterface and trait and set afterwards. or both

@HLeithner The first way I could try to do, but the better way with DatabaseAwareInterface and trait is above my level of knowledge, I think.

avatar richard67
richard67 - comment - 12 Aug 2025

@HLeithner Would that be right for the first way you suggested? 5.4-dev...richard67:5.4-dev-fix-admin-menu

avatar HLeithner
HLeithner - comment - 12 Aug 2025

Better use directly the interface and aware trait.

add the DatabaseAwareInterface DatabaseAwareTrait to the CssMenu and use $this->setDatabase($db) in the CssMenu constructor.

and I would create an extra variable for $db in the getLayoutData() method, looks better then having this long call in the constructor.

and change $table = new \Joomla\CMS\Table\MenuType($this->db); to $table = new \Joomla\CMS\Table\MenuType($this->getDatabase());

avatar HLeithner
HLeithner - comment - 12 Aug 2025

Better use directly the interface and aware trait.

add the DatabaseAwareInterface DatabaseAwareTrait to the CssMenu and use $this->setDatabase($db) in the CssMenu constructor.

and I would create an extra variable for $db in the getLayoutData() method, looks better then having this long call in the constructor.

and change $table = new \Joomla\CMS\Table\MenuType($this->db); to $table = new \Joomla\CMS\Table\MenuType($this->getDatabase());

avatar richard67
richard67 - comment - 12 Aug 2025

@HLeithner Like this? 5.4-dev...richard67:5.4-dev-fix-admin-menu (same link as before but with new branch).

avatar richard67 richard67 - change - 12 Aug 2025
Status New Closed
Closed_Date 0000-00-00 00:00:00 2025-08-12 11:07:14
Closed_By richard67
avatar richard67 richard67 - close - 12 Aug 2025
avatar richard67
richard67 - comment - 12 Aug 2025

Closing as having a pull request. Please test #45890 . Thanks in advance, and thanks a lot for reporting the issue.

avatar richard67 richard67 - change - 12 Aug 2025
Labels Removed: Release Blocker
avatar richard67 richard67 - unlabeled - 12 Aug 2025

Add a Comment

Login with GitHub to post a comment