joomla / joomla-cms

Home of the Joomla! Content Management System
https://www.joomla.org
GNU General Public License v2.0
4.73k stars 3.64k forks source link

Main category deletion / recreation issue #40529

Closed Freewindrider closed 1 year ago

Freewindrider commented 1 year ago

Steps to reproduce the issue

  1. New installation of Joomla 4.3.1
  2. Delete the main system category "uncategorized", works without errors or an alert, that at least one (system-)category should be present.
  3. The recreation a new/main category of your choice leads to the following error:

An error has occurred. 0 Joomla\CMS\Toolbar\Toolbar::versions(): Argument #2 ($itemId) must be of type int, null given, called in /home/httpd/vhosts/WHATEVER/administrator/components/com_categories/src/View/Category/HtmlView.php on line 239

Call stack

1 | () | JROOT/libraries/src/Toolbar/CoreButtonsTrait.php:511 2 | Joomla\CMS\Toolbar\Toolbar->versions() | JROOT/administrator/components/com_categories/src/View/Category/HtmlView.php:239 3 | Joomla\Component\Categories\Administrator\View\Category\HtmlView->addToolbar() | JROOT/administrator/components/com_categories/src/View/Category/HtmlView.php:121 4 | Joomla\Component\Categories\Administrator\View\Category\HtmlView->display() | JROOT/administrator/components/com_categories/src/Controller/DisplayController.php:111 5 | Joomla\Component\Categories\Administrator\Controller\DisplayController->display() | JROOT/libraries/src/MVC/Controller/BaseController.php:678 6 | Joomla\CMS\MVC\Controller\BaseController->execute() | JROOT/libraries/src/Dispatcher/ComponentDispatcher.php:143 7 | Joomla\CMS\Dispatcher\ComponentDispatcher->dispatch() | JROOT/libraries/src/Component/ComponentHelper.php:361 8 | Joomla\CMS\Component\ComponentHelper::renderComponent() | JROOT/libraries/src/Application/AdministratorApplication.php:143 9 | Joomla\CMS\Application\AdministratorApplication->dispatch() | JROOT/libraries/src/Application/AdministratorApplication.php:186 10 | Joomla\CMS\Application\AdministratorApplication->doExecute() | JROOT/libraries/src/Application/CMSApplication.php:293 11 | Joomla\CMS\Application\CMSApplication->execute() | JROOT/administrator/includes/app.php:61 12 | require_once() | JROOT/administrator/index.php:32

Expected result

Category recreation from an empty DB-table should work without problems.

Actual result

Category recreation is impossible.

System information

Joomla 4.3.1, PHP 8.2.5

Possible solutions

  1. Comment out line 239 in administrator/components/com_categories/src/View/Category/HtmlView.php >>> Category recreation works without any problems.
  2. Alert user, that at least one main category must be present, make it impossible to delete this category.
  3. Any better solution you propose :)
Fedik commented 1 year ago

Can you please test #40484 I suspect it should fix the bug.

Freewindrider commented 1 year ago

Tested this successfully, this was point 3 (a better solution). Thank you very much.

Freewindrider commented 1 year ago

Fixed in https://github.com/joomla/joomla-cms/pull/40484