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
menu item opens
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)
Labels |
Added:
No Code Attached Yet
|
Title |
|
Confirming that the same fatal error occurs in 5.4
@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)?
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.
tried both suggestions without success
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\\');
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.
Labels |
Added:
Release Blocker
bug
|
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;
}
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.
@HLeithner And how would the getLayoutData
pass the $db
object to the CssMenu
?
as written from the container
But I also said it should be done in the dispatcher but didn't looked at it yet.
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?
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).
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
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
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.
@HLeithner Would that be right for the first way you suggested? 5.4-dev...richard67:5.4-dev-fix-admin-menu
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());
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());
@HLeithner Like this? 5.4-dev...richard67:5.4-dev-fix-admin-menu (same link as before but with new branch).
Status | New | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2025-08-12 11:07:14 |
Closed_By | ⇒ | richard67 |
Labels |
Removed:
Release Blocker
|
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 thelibraries/src/Table
folder, so for these we have to stick with the deprecatedTable::getInstance
?