?
avatar frogydiak
frogydiak
7 Jul 2018

Steps to reproduce the issue

Pulled the latest 4.0-dev branch as of July 7, 2018 at 1:53PM PST, going to the frontend and getting this error:

Error: Class 'Joomla\Module\Menu\Site\Helper\MenuHelper' not found: Class 'Joomla\Module\Menu\Site\Helper\MenuHelper' not found

This is a fresh install. Actually this error appeared like 3-4 days but as of the current updates, it has not been fixed.

avatar frogydiak frogydiak - open - 7 Jul 2018
avatar joomla-cms-bot joomla-cms-bot - change - 7 Jul 2018
Labels Added: ?
avatar joomla-cms-bot joomla-cms-bot - labeled - 7 Jul 2018
avatar brianteeman brianteeman - change - 7 Jul 2018
Status New Closed
Closed_Date 0000-00-00 00:00:00 2018-07-07 21:36:13
Closed_By brianteeman
avatar brianteeman
brianteeman - comment - 7 Jul 2018

Doing a pull won't help as the file doesn't exist in the repo any more. It is built by your site. Just delete the file and let the plugin rebuild it. See #20902

avatar brianteeman brianteeman - close - 7 Jul 2018
avatar frogydiak
frogydiak - comment - 7 Jul 2018

@brianteeman I already tried #20902 and it doesn't work. Besides the regenerated file autoloader_psr4.php under /libraries/ does not have the class referred above. This issue is in the frontend and not in the administrator as what is in #20902

avatar patrickuhlmann
patrickuhlmann - comment - 30 Oct 2022

I have the same issue. I upgraded today from Joomla 3 to Joomla 4. As soon as I enable the menu the following error is displayed: Class "Joomla\Module\Menu\Site\Helper\MenuHelper" not found

I searched for occurrences and found the class under modules/mod_menu/src/Helper/MenuHelper.php. However there are no references in any autoload_psr4.php

avatar ReLater
ReLater - comment - 30 Oct 2022

there are no references in any autoload_psr4.php

The main namespace is defeined in administrator\cache\autoload_psr4.php

'Joomla\\Module\\Menu\\Site\\' => [JPATH_SITE . '/modules/mod_menu/src'],

Delete the file to force to create it newly-

Then MenuHelper.php itself defines a namespace:

namespace Joomla\Module\Menu\Site\Helper;

Therefore files like for example mod_menu.php that want to use the helper have to set a

use Joomla\Module\Menu\Site\Helper\MenuHelper;

Works for me without any issues.

avatar patrickuhlmann
patrickuhlmann - comment - 31 Oct 2022

Hm. My entry in the administrator\cache\autoload_psr4.php is
Joomla\\Module\\Menu\\Site\\' => [JPATH_SITE . '/modules/mod_menu'],

(defined without the folder /src). I deleted it and it is regenerated the file with the same entry and it still doesn't work.

I also checked the folder modules/mod_menu/src/Helper/ and found the file MenuHelper.php with said namespace.

Any idea why this can be the case?

avatar ReLater
ReLater - comment - 31 Oct 2022

Any idea why this can be the case?

Nope.

While renewal of this file:

  • Picks the namespace from manifest xml mod_menu.xml. Is the tag <namespace path="src">Joomla\Module\Menu</namespace>
  • Picks the path attribute. Is src.
  • Adds it to the detected base path which is JPATH_SITE . '/modules' . '/' . $extension.
  • All in all gives the path [JPATH_SITE . '/modules/mod_menu/src'].

All paths in administrator\cache\autoload_psr4.php should have a /src. Exceptions can be 3rd party extensions.

avatar patrickuhlmann
patrickuhlmann - comment - 6 Nov 2022

Ok I understand now what is going on.

The problem is as follows:
In the file libraries/namespacemap.php in the method getNamespaces. There is the following line:

$path            = str_replace($isAdministrator ? JPATH_ADMINISTRATOR : JPATH_SITE, '', $namespacePath);

When I output some variables the problem was clear:

namespacePath: /src/modules/mod_menu/src
JPATH_ADMINISTRATOR: /src/administrator
JPATH_SITE: /src
path: /modules/mod_menu
extension: JPATH_SITE . '/modules/mod_menu'

Actually the line should strip the administrator or site prefix. In my case i mapped the code in docker in the directory /src. Thus it will replace the first occurance of /src which is ok but it will also strip the second occurence which leads to my problem.

It would be safer to use a method that only replaces the first occurence or to restrict it to strip the prefix. In my case I can just use another directory.

avatar ReLater
ReLater - comment - 6 Nov 2022

@patrickuhlmann

It would be safer to use a method that only replaces the first occurence or to restrict it to strip the prefix. In my case I can just use another directory.

I think you should open a new issue and describe your last find there because this one here is very old.

Add a Comment

Login with GitHub to post a comment