No Code Attached Yet bug
avatar EJBJane
EJBJane
27 Jun 2024

When attempting to add or edit menu items in the Joomla Administrator backend, an error occurs stating that strlen() expects a string, but an array is given. This issue has been observed in multiple Joomla installations, indicating a possible bug in the core Joomla files related to menu management. It also has the effect of disappearing admin menu items.

Steps to reproduce the issue

Log into the Joomla Administrator Backend: Access the administrator area of a Joomla site.
Navigate to Menus: Go to Menus > Manage and select an administrator menu or try to create a new one.
Attempt to Add or Edit a Menu Item: Click on 'New' to add a new menu item or select an existing item to edit.
Observe the Error: Upon trying to create a new menu item or modify an existing one, an error message is displayed.

Expected result

The user should be able to create a new menu item or edit existing items without encountering errors. The menu item type selection should work seamlessly, allowing administrators to set up and configure backend menus.

Actual result

An error message is displayed, preventing the user from adding or editing menu items. The error details are:
Error Message: 0 strlen(): Argument #1 ($string) must be of type string, array given
Call Stack:

Function Location

1 () JROOT/administrator/components/com_menus/src/Model/MenutypesModel.php:414
2 strlen()
3 array_filter() JROOT/administrator/components/com_menus/src/Model/MenutypesModel.php:414
4 Joomla\Component\Menus\Administrator\Model\MenutypesModel->getTypeOptionsFromManifest() JROOT/administrator/components/com_menus/src/Model/MenutypesModel.php:175
5 Joomla\Component\Menus\Administrator\Model\MenutypesModel->getTypeOptionsByComponent() JROOT/administrator/components/com_menus/src/Model/MenutypesModel.php:109
6 Joomla\Component\Menus\Administrator\Model\MenutypesModel->getTypeOptions() JROOT/libraries/src/MVC/View/AbstractView.php:159
7 Joomla\CMS\MVC\View\AbstractView->get() JROOT/administrator/components/com_menus/src/View/Menutypes/HtmlView.php:62
8 Joomla\Component\Menus\Administrator\View\Menutypes\HtmlView->display() JROOT/libraries/src/MVC/Controller/BaseController.php:697
9 Joomla\CMS\MVC\Controller\BaseController->display() JROOT/administrator/components/com_menus/src/Controller/DisplayController.php:74
10 Joomla\Component\Menus\Administrator\Controller\DisplayController->display() JROOT/libraries/src/MVC/Controller/BaseController.php:730
11 Joomla\CMS\MVC\Controller\BaseController->execute() JROOT/libraries/src/Dispatcher/ComponentDispatcher.php:143
12 Joomla\CMS\Dispatcher\ComponentDispatcher->dispatch() JROOT/libraries/src/Component/ComponentHelper.php:361
13 Joomla\CMS\Component\ComponentHelper::renderComponent() JROOT/libraries/src/Application/AdministratorApplication.php:150
14 Joomla\CMS\Application\AdministratorApplication->dispatch() JROOT/libraries/src/Application/AdministratorApplication.php:195
15 Joomla\CMS\Application\AdministratorApplication->doExecute() JROOT/libraries/src/Application/CMSApplication.php:306
16 Joomla\CMS\Application\CMSApplication->execute() JROOT/administrator/includes/app.php:58
17 require_once() JROOT/administrator/index.php:32

System information (as much as possible)

System Information
Setting Value
PHP Built On Linux dedi2762.your-server.de 5.10.0-29-amd64 #1 SMP Debian 5.10.216-1 (2024-05-03) x86_64
Database Type mysql
Database Version 10.5.23-MariaDB-0+deb11u1
Database Collation utf8mb4_unicode_ci
Database Connection Collation utf8mb4_general_ci
Database Connection Encryption None
Database Server Supports Connection Encryption Yes
PHP Version 8.1.29
Web Server Apache
WebServer to PHP Interface cgi-fcgi
Joomla! Version Joomla! 5.1.0 Stable [ Kudumisha ] 16-April-2024 16:00 GMT
Joomla Backward Compatibility Plugin Enabled ()
User Agent Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36

Additional comments

See text file for full system info and added visual on Admin menus for two installations.

Votes

# of Users Experiencing Issue
1/1
Average Importance Score
5.00

avatar EJBJane EJBJane - open - 27 Jun 2024
avatar EJBJane EJBJane - change - 27 Jun 2024
Labels Removed: ?
avatar joomla-cms-bot joomla-cms-bot - change - 27 Jun 2024
Labels Added: No Code Attached Yet
avatar joomla-cms-bot joomla-cms-bot - labeled - 27 Jun 2024
avatar EJBJane EJBJane - change - 27 Jun 2024
The description was changed
avatar EJBJane EJBJane - edited - 27 Jun 2024
avatar EJBJane
EJBJane - comment - 27 Jun 2024

Multiple installations means three seperate installations.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/43715.

avatar chmst
chmst - comment - 27 Jun 2024

1 - Could you check your database, if there is an error?
2 - Could you try a "Rebuild" for your menu items?

avatar chmst chmst - change - 27 Jun 2024
Labels Added: Information Required
avatar chmst chmst - labeled - 27 Jun 2024
avatar EJBJane
EJBJane - comment - 27 Jun 2024

Hi there! Yep, done that. no errors and did a database check and no problems to be found except for perhaps _finder_tokens
and finder_tokens don't support checks but that's normal no? Rebuild done various times and doesnt make a difference. By the way, the actual content behind the links do exist in 'missing' links, otherwise I would be panicking for real. For example: I am missing several contact component links but the content is still available, like contact profiles, groups and such.

avatar ceford
ceford - comment - 27 Jun 2024

Administrator menu? What do you mean by Go to Menus > Manage and select an administrator menu or try to create a new one.

Could you post a screenshot of the error to show it in context?


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/43715.

avatar richard67
richard67 - comment - 28 Jun 2024

For example: I am missing several contact component links but the content is still available, like contact profiles, groups and such.

@EJBJane The standard links e.g. for the Contact component are added when updating from Joomla 3 (3.10) to 4. If they are missing on some of your sites it could mean that there went something wrong with that. Can you confirm that the sites which have this problem once were updated from Joomla 3? Or were these newer sites created with Joomla 4?

avatar EJBJane
EJBJane - comment - 28 Jun 2024

For example: I am missing several contact component links but the content is still available, like contact profiles, groups and such.

@EJBJane The standard links e.g. for the Contact component are added when updating from Joomla 3 (3.10) to 4. If they are missing on some of your sites it could mean that there went something wrong with that. Can you confirm that the sites which have this problem once were updated from Joomla 3? Or were these newer sites created with Joomla 4?

Okay, so two are sites that started with Joomla 4.0 and another which doesnt have anything else but Components in the admin menu upgraded from 2 to 3 to 4 and now on 5.

I confirm I had a problem with some contact links in admin menu after the migration from 4 to 5, some contact links in the admin menu were indeed not showing up. I cant remember what I did to make them reappear, it was a long time ago but it was only on the oldest website I had that problem.
To answer @ceford This problem occurs in Admin menu items. I will show you a screencast from one of the website made with joomla 4.

https://app.screencastify.com/v3/watch/NzGGM5r7qVWup4eo1R5W

avatar Hackwar
Hackwar - comment - 5 Aug 2024

The problem is this line https://github.com/joomla/joomla-cms/blob/4.4-dev/administrator/components/com_menus/src/Model/MenutypesModel.php#L412
Here we are filtering the request to remove all empty entries in that array. However we want to preserve entries with the string "0", which is why we are using strlen here. Now you have an extension installed, which uses the link attribute in it's manifest for the backend menu and that link contains an array. That is why it is having issues here.

The solution would be to replace the simple reference to strlen here with something like the following:

if(is_array($input)) {
return true;
} else {
return strlen($input);
}
}
avatar EJBJane
EJBJane - comment - 5 Aug 2024

Should I try that myself or wait until there is a patch?

avatar chmst
chmst - comment - 5 Aug 2024

Just working on a patch but if you want to contribute - would be very appreciated. So I will wait for yor PR :)

avatar Hackwar
Hackwar - comment - 5 Aug 2024

The error should be triggerable with a URL like this in the manifest of a component: index.php?option=com_foo&id[]=x

avatar chmst chmst - change - 5 Aug 2024
Labels Added: bug
Removed: Information Required
avatar chmst chmst - labeled - 5 Aug 2024
avatar chmst chmst - unlabeled - 5 Aug 2024
avatar brianteeman
brianteeman - comment - 5 Aug 2024

Same issue #39758 ?

avatar Hackwar
Hackwar - comment - 5 Aug 2024

Yes, indeed. I was actually wondering when you would use such a link, but the OSMap usecase is very valid and we probably will see similar stuff in the future in the core even.

avatar EJBJane
EJBJane - comment - 5 Aug 2024

I will wait. :-) thanks for your work. it is much appreciated.

avatar alikon alikon - close - 6 Aug 2024
avatar alikon alikon - change - 6 Aug 2024
Status New Closed
Closed_Date 0000-00-00 00:00:00 2024-08-06 05:47:38
Closed_By alikon
avatar alikon
alikon - comment - 6 Aug 2024

please test #43884

Add a Comment

Login with GitHub to post a comment