User tests: Successful: Unsuccessful:
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.
Set Children parameter to false in delete
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.
Record disapears, the rest of the records remain.
All records are erased.
Category | ⇒ | Libraries |
Status | New | ⇒ | Pending |
Title |
|
I have tested this item
Code review.
Besides my doubts (above) but there is no better solution now. I mark it as success.
I have tested this item
Status | Pending | ⇒ | Ready to Commit |
RTC after two successful tests.
It depends how much is your database table corrupted.
If there is no errors then there should not be any children because all menu items of the component are deleted, one by one.
Otherwise, for example, if the values of column lft
and rgt
are corrupted for items X and Y that are contained (based on lft
and rgt
values) in item Z and you want to delete Z, then X and Y will be move one level up, lft
and rgt
will be updated, [X,Y].parent_id
= Z.parent_id
. This is the good side. The bad side is, when you delete corrupted item, you could move others menu items to one level up and other menu items may start be corrupted too.
If you want to read the code then take a look at code that I pasted above, joomla-cms/libraries/src/Table/Nested.php
line 625.
Such operation, delete
, runs a few sql queries in non atomic operation, executed separately and based on lft
column, which is not unique in database tables.
Status | Ready to Commit | ⇒ | Fixed in Code Base |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2017-11-01 12:04:27 |
Closed_By | ⇒ | mbabker | |
Labels |
Added:
?
|
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