?
avatar anibalsanchez
anibalsanchez
7 Jul 2016

Steps to reproduce the issue

I've been testing the latest builds of Joomla 3.6 and I've just noticed that when I install an extension. _removeAdminMenus removes not only admin menu items associated with the extension.

I've found how to reproduce the issue with Weblinks.

The key to force the bug is in the order of menu items.

  1. Modify _removeAdminMenus to force an inverse order of deletion, libraries/cms/installer/adapter/component.php, line 1087

    // Get the ids of the menu items
    $query = $db->getQuery(true)
                ->select('id')
                ->from('#__menu')
                ->where($db->quoteName('client_id') . ' = 1')
                ->where($db->quoteName('component_id') . ' = ' . (int) $id)
                ->order('id desc');
    
  2. Install Weblinks.

  3. Manually add a menu item (any type)
  4. Install Weblinks again.
  5. New menu item is removed!

Expected result

Only extension admin menu items must be deleted

Actual result

Extra menu items are removed

System information (as much as possible)

Joomla 3.6 RC2
MySQL Server version: 5.5.49-0ubuntu0.14.04.1
PHP 5.6.23-1

Additional comments

I have tested two solutions:

  1. The list of menu items must be visited orderly

    // Get the ids of the menu items
    $query = $db->getQuery(true)
                ->select('id')
                ->from('#__menu')
                ->where($db->quoteName('client_id') . ' = 1')
                ->where($db->quoteName('component_id') . ' = ' . (int) $id);
                ->order('id');
    
  2. JTableNested cannot compress "the left and right values" since it is not adjusting the width of the parent node.

        // Compress the left and right values.
        /*
        $query->clear()
            ->update($this->_tbl)
            ->set('lft = lft - ' . (int) $node->width)
            ->set('rgt = rgt - ' . (int) $node->width)
            ->where('lft > ' . (int) $node->rgt);
            */
    

Please, note that when the list of menu items is NOT ordered and it is returned by MySQL in any order, then the parent node has the orignal width (rgt-lft). If it is the last item of the list, it includes other menu items.

avatar anibalsanchez anibalsanchez - open - 7 Jul 2016
avatar anibalsanchez anibalsanchez - change - 7 Jul 2016
The description was changed
avatar anibalsanchez anibalsanchez - change - 7 Jul 2016
The description was changed
avatar mbabker
mbabker - comment - 7 Jul 2016

You're going to have to give a lot better reproduction instructions to get anywhere with this one. Assuming you mean JInstallerAdapterComponent::_removeAdminMenus() and not some custom code the query in question already filters on admin menu items only (ordering is irrelevant here unless you're only looking for parent items and will rely on the JTable API to delete its children).

Also the left/right values should be updated so as to ensure the nested data set is correct, I'd advise against not executing that query.

If a frontend menu item is being assigned as the child item of an admin menu item, that is a major error with how the menu items are being inserted. Considering the data set you're giving is nothing but a bunch of IDs, it's hard to say what's going on.

avatar anibalsanchez
anibalsanchez - comment - 7 Jul 2016

Hi Michael,

Sorry to be unclear. Yes, you are right. I'm referring to JInstallerAdapterComponent::_removeAdminMenus().

No, a frontend menu item is not being assigned as the child item of an admin menu item. Menu items are consistent.

The error is found when _removeAdminMenus() is executed with a list of admin menu items not ordered by ID.

I think that the main clue of the problem is that JTableNested re-arranges lft and rgt values ... and parent node keeps the same values until the end... when it has invalid values.

I'm going to try to reproduce it in a Joomla demo site.

avatar anibalsanchez
anibalsanchez - comment - 7 Jul 2016

Addtionally, I can only reproduce it in Joomla 3.6 RC.

avatar ggppdk
ggppdk - comment - 7 Jul 2016

There is no problem with the SQL query of the method
_removeAdminMenus

if this bug exists it must be a problem with method ?

JTableNested::delete

is this change relevant ?
2819529

avatar anibalsanchez
anibalsanchez - comment - 7 Jul 2016

Hi @ggppdk , Yes, it's related with that modification.

I've found how to reproduce the issue with Weblinks.

The key to force the bug is in the order of menu items.

  1. Modify _removeAdminMenus to force an inverse order of deletion, libraries/cms/installer/adapter/component.php, line 1087

    // Get the ids of the menu items
    $query = $db->getQuery(true)
                ->select('id')
                ->from('#__menu')
                ->where($db->quoteName('client_id') . ' = 1')
                ->where($db->quoteName('component_id') . ' = ' . (int) $id)
                ->order('id desc');
    
  2. Install Weblinks.

  3. Manually add a menu item (any type)
  4. Install Weblinks again.
  5. New menu item is removed!
avatar anibalsanchez anibalsanchez - change - 7 Jul 2016
The description was changed
avatar anibalsanchez
anibalsanchez - comment - 7 Jul 2016

Hi @wilsonge , please, check this issue that removes menu items.

avatar ggppdk
ggppdk - comment - 7 Jul 2016

Ok @anibalsanchez @mbabker
i confirm the issue of wrong menu items being deleted !

  • a fix is to move the $table->rebuild() inside the deletion loop, thus executing a rebuild after every menu deletion

Is this performance unwise ? maybe rebuild() can be changed to be limited to a subtree ?

Also the bug, seems to be a side effect of the changes made to:
JTableNested::delete()

  • now rebuild() is required to be called after every deletion ?

was this required before ?

is there other code similar to _removeAdminMenus() ?
are there 3rd party extensions that can be using similar code ?

This is a release blocker ?

avatar wilsonge wilsonge - change - 7 Jul 2016
Labels Added: ?
avatar anibalsanchez
anibalsanchez - comment - 7 Jul 2016

Yes. It is a release blocker.

This a case about menu items, but it could also affect other cases
associated with nested table usage.
On Jul 7, 2016 8:53 PM, "Georgios Papadakis" notifications@github.com
wrote:

Ok @anibalsanchez https://github.com/anibalsanchez @mbabker
https://github.com/mbabker
i confirm the issue of wrong menu items being deleted !

  • a fix is to move the $table->rebuild() inside the deletion loop, thus executing a rebuild after every menu deletion

Is this seems performance unwise ? maybe rebuild() can be changed to
limited to a subtree ?

Also the bug, seems to be a side effect of the changes made to:
JTableNested::delete()

  • now rebuild() is required to be called after every deletion ?

is there are other code similar to _removeAdminMenus() ?
are 3rd party extensions that can be using similar code ?

This is a release blocker ?


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#11044 (comment),
or mute the thread
https://github.com/notifications/unsubscribe/AAXi9PnLyZegQAQ7ntF0L7sw7j7pe39eks5qTUs5gaJpZM4JHJzK
.

avatar wilsonge
wilsonge - comment - 7 Jul 2016

I've set a release blocker label and pinged the maintainer team in glip to make them aware. I'm away on holiday until saturday evening. If no one picks up on it by then, I'll deal with things here on my return

avatar brianteeman brianteeman - change - 8 Jul 2016
Labels Added: ?
avatar anibalsanchez anibalsanchez - reference | 224a7bc - 11 Jul 16
avatar infograf768 infograf768 - change - 11 Jul 2016
Status New Closed
Closed_Date 0000-00-00 00:00:00 2016-07-11 18:19:59
Closed_By infograf768
avatar joomla-cms-bot joomla-cms-bot - close - 11 Jul 2016
avatar infograf768
infograf768 - comment - 11 Jul 2016
avatar joomla-cms-bot joomla-cms-bot - close - 11 Jul 2016
avatar wilsonge wilsonge - close - 11 Jul 2016
avatar infograf768
infograf768 - comment - 11 Jul 2016

closed as we have a patch


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

avatar wilsonge wilsonge - change - 11 Jul 2016
Labels Removed: ?

Add a Comment

Login with GitHub to post a comment