[4.3] Fix wrong lft and rgt values in assets table#40237
Merged
obuisard merged 3 commits intojoomla:4.3-devfrom Mar 30, 2023
Merged
[4.3] Fix wrong lft and rgt values in assets table#40237obuisard merged 3 commits intojoomla:4.3-devfrom
obuisard merged 3 commits intojoomla:4.3-devfrom
Conversation
4 tasks
Contributor
|
I have tested this item ✅ successfully on cd26415 This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/40237. |
1 similar comment
Contributor
|
I have tested this item ✅ successfully on cd26415 This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/40237. |
Member
Author
|
RTC This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/40237. |
Contributor
|
Thanks for the PR Richard @richard67. Great instructions as well, worth keeping. |
Denitz
pushed a commit
to Denitz/joomla-cms
that referenced
this pull request
Apr 1, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 #40208 (comment) .
Summary of Changes
This pull request (PR) corrects the following two mistakes with lft and rgt values for the nested
#__assetstable for new installations:https://github.com/joomla/joomla-cms/blob/4.3-dev/installation/sql/mysql/base.sql#L70
https://github.com/joomla/joomla-cms/blob/4.3-dev/installation/sql/mysql/base.sql#L89
Both are assets for single modules on level 2 below the 'com_modules' asset.
This error was introduced with PR Fixing #__assets table #30178 , possibly not with the initial version of that PR but when resolving merge conflicts with the base branch.
Because the same PR had removed some obsolete assets, we are lucky and the lft and rgt values 78 and 79 are not used, so they are a gap on that level with that parent, which as such is not a problem but helps here to fix the issue. We can change the the lft and rgt values of asset ID 67 and 68 to the previous values plus one, and so that gap is filled, too, and the nested table is correct.
https://github.com/joomla/joomla-cms/blob/4.3-dev/installation/sql/mysql/base.sql#L28
https://github.com/joomla/joomla-cms/blob/4.3-dev/installation/sql/mysql/base.sql#L115
This error was introduced with PR GSoC’22 project: Guided Tours #39902 .
When the rgt value of the root asset is smaller than the one of the last child, it is not updated to a new value when a new asset is added for something, e.g. by creating a new category or installing a new module and then editing that asset. This can also be seen when reproducing issue [4.3] guided tours - assets table #40199 .
Testing Instructions
Testers need to know and have understood the principles of hierarchical tables using the nested set model as described here:
https://en.wikipedia.org/wiki/Nested_set_model
The
#__assetstable uses an extended model which saves as redundant information alsoparent_idandlevelin addition tolftandrgtfor speeding up certain queries.As the structure of the assets table is only a few levels deep, the nested table can be easily verified in tools like phpMyAdmin or phpPgAdmin.
For this you can either make a new installation with the branch of this PR, or you simply use an empty database and execute the statements to create the assets table and insert the records from the base.sql file of this PR.
Then you select all records from the table and order by the
lftcolumn in ascending order. Make sure that really all records are shown.Then go through the lft and rgt values from top to bottom and lft to rgt, and when at the end of a child level from the last rgt value on that level back to the rgt value of the parent further above. So just follow the lft and rgt values as described on this Wikipedia page about the nested model. Check that the sequence of lft and rgt values is according to that model and that the parent ID and the level are correct, too.
Check that the changes of this PR are correct.
For issue 2. you can also add a new asset e.g. by adding a new category or by reproducing issue #40199 . Make sure that the rgt value of the root asset is updated, too, when the new asset is added.
Actual result BEFORE applying this Pull Request
Expected result AFTER applying this Pull Request
Link to documentations
Please select:
No documentation changes for docs.joomla.org needed
No documentation changes for manual.joomla.org needed