Create a menu item that points to something belonging to a component. For example a form in Chronoforms.
Remove that component (perhaps you've installed a newer version of it)
You can see that the menu page shows you "component not found". Try to edit the menu item.
Be able to edit the menu item to be able to point it elsewhere (for example a newer version of the component)
Stack trace is produced as follows:
1 () JROOT/libraries/vendor/joomla/filesystem/src/Path.php:194
2 Joomla\Filesystem\Path::clean() JROOT/administrator/components/com_menus/src/Model/ItemModel.php:1131
3 Joomla\Component\Menus\Administrator\Model\ItemModel->preprocessForm() JROOT/libraries/src/MVC/Model/FormBehaviorTrait.php:115
4 Joomla\CMS\MVC\Model\FormModel->loadForm() JROOT/administrator/components/com_menus/src/Model/ItemModel.php:517
5 Joomla\Component\Menus\Administrator\Model\ItemModel->getForm() JROOT/libraries/src/MVC/View/AbstractView.php:159
6 Joomla\CMS\MVC\View\AbstractView->get() JROOT/administrator/components/com_menus/src/View/Item/HtmlView.php:88
7 Joomla\Component\Menus\Administrator\View\Item\HtmlView->display() JROOT/libraries/src/MVC/Controller/BaseController.php:697
8 Joomla\CMS\MVC\Controller\BaseController->display() JROOT/administrator/components/com_menus/src/Controller/DisplayController.php:74
9 Joomla\Component\Menus\Administrator\Controller\DisplayController->display() JROOT/libraries/src/MVC/Controller/BaseController.php:730
10 Joomla\CMS\MVC\Controller\BaseController->execute() JROOT/libraries/src/Dispatcher/ComponentDispatcher.php:143
11 Joomla\CMS\Dispatcher\ComponentDispatcher->dispatch() JROOT/libraries/src/Component/ComponentHelper.php:361
12 Joomla\CMS\Component\ComponentHelper::renderComponent() JROOT/libraries/src/Application/AdministratorApplication.php:150
13 Joomla\CMS\Application\AdministratorApplication->dispatch() JROOT/libraries/src/Application/AdministratorApplication.php:195
14 Joomla\CMS\Application\AdministratorApplication->doExecute() JROOT/libraries/src/Application/CMSApplication.php:306
15 Joomla\CMS\Application\CMSApplication->execute() JROOT/administrator/includes/app.php:58
16 require_once() JROOT/administrator/index.php:32
Joomla! Version Joomla! 5.1.0 Stable [ Kudumisha ] 16-April-2024 16:00 GMT
In the file JROOT/libraries/vendor/joomla/filesystem/src/Path.php
In this scenario the $path is a boolean, not a string (because the component doesn't exist)
At this statement:
public static function clean($path, $ds = \DIRECTORY_SEPARATOR)
{
if (!\is_string($path)) {
throw new \InvalidArgumentException('You must specify a non-empty path to clean');
}
Before the if statement, you could check if $path is (presumably) False, and if so, just return. There is no need to crash out. This enables the editing of the menu item to proceed without the user having to resort to editing the Path.php file to fix it, or having to delete their menu item and re-create it. A stack trace is never desirable when a simple fix can be made.
Labels |
Removed:
?
|
Labels |
Added:
No Code Attached Yet
|
Hi Brian. Ah yes! I do have debug on and you are correct. It would still be preferable to enable the user to edit the menu item than to receive the error.
I've never submitted a pull request before, and I don't know if the fix I would suggest is acceptable, however it works for me (tested) by simply replacing the "throw new..." line I quoted above with "return;"
The thing I don't know is if there are ever any circumstances where one would desire the error message instead of silently ignoring the problem because I don't have enough in-depth knowledge of the code that may call it under other circumstances. It certainly fixes this specific scenario.
I shall see if I can submit the pull request. :-)
Labels |
Added:
bug
|
I think your fix is at the wrong place and would have to many side effects. Then main problem here is that the application can't load the form definition for the menu item. This is something you can't fix in a proper way. I think in such situations deleting the menu item and creating a new one would be the way to go.
Status | New | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2024-06-03 06:34:53 |
Closed_By | ⇒ | alikon |
You only get the stack trace if you have debug enabled. In normal use you get
But if you have a fix that is more helpful please submit a pull request with that code