No Code Attached Yet bug
avatar rachelwalraven
rachelwalraven
29 Jan 2023

The issue

Whene you move a categorie to a parent category this the batch process the first time the categorie disappears, after that moving a category will result in an error: Batch process failed with following error: Another category with the same parent category has the same alias. Moving a child element to another parent or to the root gives the same error.
This error occurse even when the selected parent has no other children and there are no duplicate aliases. Even in the trash.

Steps to reproduce the issue

Create 2 of more categories.
Select 1 of more categories.
Click 'Actions' and choose batch.
Select a parent category at 'Copy or Move to Category'.
Leave all other settings and click 'Process'

Expected result

Selected categories are now children of the selected parent category

Actual result

The first time you do this the categorie(s) will disappear.
The secont time you will get the error 'Batch process failed with following error: Another category with the same parent category has the same alias.'
No categories are moved.

System information (as much as possible)

Joomla 4.2.7 RC1, PHP Version 8.0.27

Additional comments

Other tester confirmed this problem.

avatar rachelwalraven rachelwalraven - open - 29 Jan 2023
avatar rachelwalraven rachelwalraven - change - 29 Jan 2023
Labels Removed: ?
avatar joomla-cms-bot joomla-cms-bot - change - 29 Jan 2023
Labels Added: No Code Attached Yet
avatar joomla-cms-bot joomla-cms-bot - labeled - 29 Jan 2023
avatar rachelwalraven rachelwalraven - change - 29 Jan 2023
The description was changed
avatar rachelwalraven rachelwalraven - edited - 29 Jan 2023
avatar chmst
chmst - comment - 29 Jan 2023

confirmed

avatar chmst chmst - change - 29 Jan 2023
Labels Added: bug
avatar chmst chmst - labeled - 29 Jan 2023
avatar chmst chmst - change - 29 Jan 2023
Labels Added: Release Blocker
avatar chmst chmst - labeled - 29 Jan 2023
avatar richard67
richard67 - comment - 29 Jan 2023

I could reproduce the issue with 4.2.6, so it's not a regression from 4.2.7-rc1.

avatar richard67
richard67 - comment - 29 Jan 2023

I created 3 categories. First I have moved the 2nd one to the 1st one. The 2nd one disappeared in the list view. Then I have tried to move the 3rd one to the 2nd one and got the error message about duplicate alias.

In database, the 2nd category has lost all its values and so has lft and rgt and level = 0, path = 'root', title and alias are empty and description and params = NULL and so on.

Of course when the same happens to the 3rd category when trying to move it, it will have the same empty alias as the 2nd has, therefore the error message.

avatar richard67
richard67 - comment - 29 Jan 2023

The 2nd category formerly known as "Test Category 2" in database:

j4 2-issue-39742-db

avatar richard67
richard67 - comment - 29 Jan 2023

As you can see in the above screenshot, the category also has a new asset id 94 instead of the 92 it should still have.

avatar brianteeman
brianteeman - comment - 29 Jan 2023

I'm sure we have an old open issue for this

avatar joomdonation
joomdonation - comment - 29 Jan 2023

@richard67 Could you try to revert the change from this PR #39158 to see if it solves the issue? Have to read the code more carefully but I think the code on this line https://github.com/joomla/joomla-cms/blob/4.2-dev/administrator/components/com_categories/src/Model/CategoryModel.php#L1174 reset the category data and it causes data lost as you found.

avatar richard67
richard67 - comment - 29 Jan 2023

I'm sure we have an old open issue for this

@brianteeman Maybe this? #19381

avatar richard67
richard67 - comment - 29 Jan 2023

Or this? #39137 ... but this was the one for which PR #39158 was the solution.

avatar richard67
richard67 - comment - 29 Jan 2023

@joomdonation Can't check that right now because have to do something else which can not wait. Will check later.

avatar richard67
richard67 - comment - 29 Jan 2023

@joomdonation I took the time and checked. It works when I revert the change from PR #39158 . But this would bring back issue #39137 , right?

avatar joomdonation
joomdonation - comment - 29 Jan 2023

@richard67 Yes, it would bring back the issue. But we should be able to fix it without reverting the original PR.
Instead of using existing $this->table object to load data for validation (which causes data lost for category being processed), we can use a new table object. I will try to read code to understand the logic more and if it is all OK, I will make PR.

avatar richard67
richard67 - comment - 29 Jan 2023

@joomdonation George @wilsonge had some concert after that PR had been merged by me, see his comment there: #39158 (comment) . But he never replied my question if we should revert that PR. Maybe you should check his comment before you make your PR.

avatar joomdonation joomdonation - change - 29 Jan 2023
Status New Closed
Closed_Date 0000-00-00 00:00:00 2023-01-29 15:57:28
Closed_By joomdonation
avatar joomdonation joomdonation - close - 29 Jan 2023
avatar joomdonation
joomdonation - comment - 29 Jan 2023

@richard67 Yes, I read the comment. It would be perfect if we make it works like that. However, at the moment, there is no easy way. We will need to discuss more about how should we handle it :

  • When there is a category error but others moved successfully, what we should report the result back as success or fail ?
  • What would be the messages to tell users that some categories were success, some other fails...

Further more, we are already using the same logic in the process. When the first category failed, we stop the process (in the permission validation before we doing the move). With that said, I made PR #39744 to fix this release blocker issue. Any other improvements could be done later.

avatar richard67 richard67 - change - 29 Jan 2023
Labels Removed: Release Blocker
avatar richard67 richard67 - unlabeled - 29 Jan 2023

Add a Comment

Login with GitHub to post a comment