Skip to content

Version restore with categories doesn't work #39404

@robbiejackson

Description

@robbiejackson

Steps to reproduce the issue

Ensure that Enable Versions is Yes for articles.
Save a number of versions of the same com_content category.
Then when editing the category, click on the Versions button.
Within the modal window select an older version of the category and click on the Restore button.

Expected result

The previous version should be shown in the category edit form.

Actual result

Error 404 is returned.
The traceback shows

Call stack

| Function | Location

1 | () | JROOT\libraries\src\Component\ComponentHelper.php:351
2 | Joomla\CMS\Component\ComponentHelper::renderComponent() | JROOT\libraries\src\Application\AdministratorApplication.php:143
3 | Joomla\CMS\Application\AdministratorApplication->dispatch() | JROOT\libraries\src\Application\AdministratorApplication.php:186
4 | Joomla\CMS\Application\AdministratorApplication->doExecute() | JROOT\libraries\src\Application\CMSApplication.php:294
5 | Joomla\CMS\Application\CMSApplication->execute() | JROOT\administrator\includes\app.php:61
6 | require_once() | JROOT\administrator\index.php:32

System information (as much as possible)

Joomla 4.2.5 on Windows 10

Additional comments

Whenever the Restore button is clicked it generates a GET to a URL of the form:

http://localhost/j4hw/administrator/index.php?option=com_categoriesampextensioncom_content&task=category.loadhistory&fc703ee9b61e0e019f126ea5e8460952=1&version_id=29

This fails in ComponentHelper because it takes the option as com_categoriesampextensioncom_content and can't find a component of that name.

I think that the problem is in administrator\components\com_contenthistory\src\View\History\HtmlView.php::addToolbar

The code

$option = $aliasArray[1] == 'category'
        ? 'com_categories&extension=' . implode('.', array_slice($aliasArray, 0, count($aliasArray) - 2))
        : $aliasArray[0];

sets the $option to com_categories&extension=com_content

Then the line:

$loadUrl    = Route::_('index.php?option=' . $filter->clean($option, 'cmd') . '&task=' . $task . '&' . $token . '=1');

results in

$filter->clean($option, 'cmd')

removing the non-alpha characters from the $option to leave com_categoriesampextensioncom_content, which then gets incorporated into the url.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions