Skip to content

Fixed wrong lft/rgt values after uninstalling a component with categories#7660

Merged
rdeutz merged 1 commit intojoomla:stagingfrom
bembelimen:patch-8
Aug 13, 2016
Merged

Fixed wrong lft/rgt values after uninstalling a component with categories#7660
rdeutz merged 1 commit intojoomla:stagingfrom
bembelimen:patch-8

Conversation

@bembelimen
Copy link
Copy Markdown
Contributor

@bembelimen bembelimen commented Aug 8, 2015

If you uninstall a component with categories, the categories will be deleted by the component. But the deletion just removes the entries without proper nested sets handling. So the rgt/lft values are wrong.

This patch fixes this issue.

How to test:

  1. Look into #__categories for the entry "root.1" and remember the "rgt" value
  2. Uninstall a component which uses categories
  3. Look into the table again => the rgt value did not change (although we have a lower number of categories)
  4. Apply patch
  5. Try again

=> the rgt value is now correct

@mbabker
Copy link
Copy Markdown
Contributor

mbabker commented Aug 8, 2015

In theory it should work, in reality we should probably be using JTableCategory to do the deletions since that will handle updating the tree indexes (lft/rgt) too.

@Bakual
Copy link
Copy Markdown
Contributor

Bakual commented Aug 8, 2015

in reality we should probably be using JTableCategory to do the deletions since that will handle updating the tree indexes (lft/rgt) too.

In theory, it should do that. In practice I couldn't find where it does. 😄
I checked both the models and the table. Do you know where it does the rebuild (serious question)?

@mbabker
Copy link
Copy Markdown
Contributor

mbabker commented Aug 8, 2015

JTableNested::delete() deals with it (JTableCategory extends this class and doesn't override the method).

@bembelimen
Copy link
Copy Markdown
Contributor Author

I'm not sure, if server survive a delete-call when there are thausands of categories, which will be rebuild after every deletion. Here we make the rebuild only once...

@mbabker
Copy link
Copy Markdown
Contributor

mbabker commented Aug 8, 2015

IMO we shouldn't be using rebuild as a general function but rather use the API the "right" way. It would mean a few more queries (we should be able to do a query to get a list of all the parent categories for the extension and delete those one by one which by default deletes its children too), but it would be less prone to error. #7551 demonstrates one case where altering stuff in a nested table then running rebuild can cause issues.

@Bakual
Copy link
Copy Markdown
Contributor

Bakual commented Aug 8, 2015

JTableNested::delete() deals with it ( JTableCategory extends this class and doesn't override the method).

Blind me. I looked at JTableNested::delete() but was looking for a call to rebuild(). Didn't expect it doing the SQL directly.

@Hackwar
Copy link
Copy Markdown
Member

Hackwar commented Feb 23, 2016

In theory I agree with @mbabker that we should use the API to delete the entries. In praxis this would kill every server. Even when deleting just a few dozen categories, I had very good servers crap out. Our nested sets implementation for editing is absolutely horrible in terms of performance. The fact that we need rebuild() at all is a problem in itself. As long as we don't fix our nested sets implementation, this is the only viable solution. (And even then I fear it is not going to be enough)

From my perspective, this is good to go. Since this is one of these "can't be tested"-changes, I could give this a placebo-"tested-successfully", but otherwise we can simply merge this in.

@chrisdavenport
Copy link
Copy Markdown
Contributor

Michael is of course correct, but I don't see any reason not to merge this PR in the meantime. Improving JTableNested is another (important) issue which should be looked at separately.


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/7660.

@krim404
Copy link
Copy Markdown

krim404 commented Aug 1, 2016

I have tested this item ✅ successfully on b0a9b31

Works as described in test scenario. rgt value changed successfully. @icampus


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/7660.

@mxkmp
Copy link
Copy Markdown

mxkmp commented Aug 2, 2016

tested it @icampus

followed the description. rgt value changed sucessfully after the patch.


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/7660.

@mxkmp
Copy link
Copy Markdown

mxkmp commented Aug 2, 2016

I have tested this item ✅ successfully on b0a9b31

tested it @icampus

followed the description. rgt value changed sucessfully after the patch.


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/7660.

@brianteeman
Copy link
Copy Markdown
Contributor

RTC


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/7660.

@joomla-cms-bot joomla-cms-bot added the RTC This Pull Request is Ready To Commit label Aug 2, 2016
@brianteeman brianteeman added this to the Joomla 3.6.3 milestone Aug 4, 2016
@rdeutz rdeutz merged commit b255c97 into joomla:staging Aug 13, 2016
@joomla-cms-bot joomla-cms-bot removed the RTC This Pull Request is Ready To Commit label Aug 13, 2016
ggppdk pushed a commit to ggppdk/joomla-cms that referenced this pull request Aug 19, 2016
roland-d pushed a commit to roland-d/joomla-cms that referenced this pull request Sep 11, 2016
@bembelimen bembelimen deleted the patch-8 branch May 15, 2018 09:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants