Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Admin Menu Creation Error - strlen() expects string, array given. #43715

Closed
EJBJane opened this issue Jun 27, 2024 · 14 comments
Closed

Admin Menu Creation Error - strlen() expects string, array given. #43715

EJBJane opened this issue Jun 27, 2024 · 14 comments

Comments

@EJBJane
Copy link

EJBJane commented Jun 27, 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.

@EJBJane
Copy link
Author

EJBJane commented Jun 27, 2024

Multiple installations means three seperate installations.


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

@chmst
Copy link
Contributor

chmst commented Jun 27, 2024

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

@EJBJane
Copy link
Author

EJBJane commented Jun 27, 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.

@ceford
Copy link
Contributor

ceford commented Jun 27, 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.

@richard67
Copy link
Member

richard67 commented Jun 28, 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?

@EJBJane
Copy link
Author

EJBJane commented Jun 28, 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

@Hackwar
Copy link
Member

Hackwar commented Aug 5, 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);
}
}

@EJBJane
Copy link
Author

EJBJane commented Aug 5, 2024

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

@chmst
Copy link
Contributor

chmst commented Aug 5, 2024

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

@Hackwar
Copy link
Member

Hackwar commented Aug 5, 2024

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

@brianteeman
Copy link
Contributor

Same issue #39758 ?

@Hackwar
Copy link
Member

Hackwar commented Aug 5, 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.

@EJBJane
Copy link
Author

EJBJane commented Aug 5, 2024

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

@alikon
Copy link
Contributor

alikon commented Aug 6, 2024

please test #43884

@alikon alikon closed this as completed Aug 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants