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.
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.
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.
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:
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
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
See text file for full system info and added visual on Admin menus for two installations.
Labels |
Removed:
?
|
Labels |
Added:
No Code Attached Yet
|
1 - Could you check your database, if there is an error?
2 - Could you try a "Rebuild" for your menu items?
Labels |
Added:
Information Required
|
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.
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?
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?
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.
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);
}
}
Should I try that myself or wait until there is a patch?
Just working on a patch but if you want to contribute - would be very appreciated. So I will wait for yor PR :)
The error should be triggerable with a URL like this in the manifest of a component: index.php?option=com_foo&id[]=x
Labels |
Added:
bug
Removed: Information Required |
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.
I will wait. :-) thanks for your work. it is much appreciated.
Status | New | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2024-08-06 05:47:38 |
Closed_By | ⇒ | alikon |
Multiple installations means three seperate installations.
This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/43715.