-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Removing menu children on component install can destroy the whole menu tree #18404
Conversation
Menu table inherits Nested and since delete without second argument set to false, removes node and its children. As all child ids that need to be removed are already collected in previous step this means: a) errors are generated if three is consistent - all children are already removed in first delete, so all following deletes fail b) with inconsistent threes this can delete random ranges of menus as delete only looks at lft-rgt values. This is not a unusual scenario as admin menus were previously not checked for consistency - I just had the whole menu wiped out due to faulty record. To prevent this I propose that we delete only explicit records as I assume was also originally intended due to ids collection in previous step.
It helps because it do not need to delete children, which are already checked. But it still leaves a mess after call this: joomla-cms/libraries/src/Table/Nested.php Lines 625 to 659 in e0e8c95
|
I have tested this item ✅ successfully on 904d02b Besides my doubts (above) but there is no better solution now. I mark it as success. This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/18404. |
@csthomas open a new issue for that |
I have tested this item ✅ successfully on 904d02b This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/18404. |
RTC after two successful tests. |
It depends how much is your database table corrupted.
If you want to read the code then take a look at code that I pasted above, Such operation, |
Menu table inherits Nested and since delete without second argument set to false, removes node and its children. As all child ids that need to be removed are already collected in previous step this means:
a) errors are generated if tree is consistent - all children are already removed in first delete, so all following deletes fail
b) with inconsistent trees this can delete random ranges of menus as delete only looks at lft-rgt values. This is not a unusual scenario as admin menus were previously not checked for consistency - I just had the whole menu wiped out due to faulty record.
To prevent this I propose that we delete only explicit records as I assume was also originally intended due to ids collection in previous step.
Summary of Changes
Set Children parameter to false in delete
Testing Instructions
Copy existing record from menu tree from one of installed 3rd party components (needs to be installable, not core) to create a faulty record: : copy existing record, change parent to non-existing id and set lft to 0 and rgt to 99999. It needs to be an admin menu (client = 1 ).
Update(reinstall) component with faulty record.
Expected result
Record disapears, the rest of the records remain.
Actual result
All records are erased.
Documentation Changes Required