Fix missing lft rgt nested tree rebuild in usergroups table when deleting usergroup(s) #28684
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Pull Request for Issue #28522 (comment).
Summary of Changes
When deleting one or more usergroups, the
lft
andrgt
values in the#__usergroups
table are not recalculated, i.e. the nested set tree is not rebuilt.This PR adds the missing function call for that purpose to the delete routine of the
Usergroup
table class.Testing Instructions
On a clean, new installation, check with an SQL client (e.g. phpMyAdmin when using MySQL or MariaDB) the content of the
#__usergroups
as follows:In backend as a super user and not being member of one of these groups, delete the usergroup "Manager", which will also delete its child group "Administrator". (You can also delete others but then it's on you to calculate the right
lft
andrgt
values to check if this PR is right.)Check again with an SQL client the content of the
#__usergroups
with the same SQL query as before.Result:
lft
andrgt
values in the#__usergroups
table haven't changed for the remaining records:If you want to delete in the next test the same user group as in the test before: Make a new installation.
Apply the patch.
Repeat steps 2 and 3.
Result:
lft
andrgt
values in the#__usergroups
table have been recalculated. If you have deleted the group as described above, it should look as follows:The calculation scheme is as follows for that example:
Expected result
The
lft
andrgt
values in the#__usergroups
table are correctly recalculated.Actual result
The
lft
andrgt
values in the#__usergroups
table are not recalculated.Documentation Changes Required
None.
Additional information
When inserting new user groups or moving some around between parent groups, the
lft
andrgt
values in the#__usergroups
table are recalculated without this patch using the same function, so I assume thelft
andrgt
values are still relevant.