I want to create a menu structure where several menu entries point to the same node (for example, node/1). When I click the "a", "b" or "c" item I want to go to the node number 1 and see that branch of the menu expanded as shown in the next example.

*a ----------> node/1
  *b --------> node/1
    *c ------> node/1
  *d --------> node/998
*e ----------> node/999

Often it just works right, but sometimes I get the menu contracted. For expample, clicking "a" menu entry leads to the following result:

*a ----------> node/1
*e ----------> node/999

It is due the order the menu entries are inserted in the database. Table entries for the second example are shown in the next table:

+---------------+------+------+-----------+------------+-------+-----+-----+-----+----+----+----+----+----+----+
| menu_name     | mlid | plid | link_path | link_title | depth | p1  | p2  | p3  | p4 | p5 | p6 | p7 | p8 | p9 |
+---------------+------+------+-----------+------------+-------+-----+-----+-----+----+----+----+----+----+----+
| primary-links |  399 |    0 | node/1    | Title a    |     1 | 399 |   0 |   0 |  0 |  0 |  0 |  0 |  0 |  0 |
| primary-links |  400 |  399 | node/1    | Title b    |     2 | 399 | 400 |   0 |  0 |  0 |  0 |  0 |  0 |  0 |
| primary-links |  401 |  400 | node/1    | Title c    |     3 | 399 | 400 | 401 |  0 |  0 |  0 |  0 |  0 |  0 |
+---------------+------+------+-----------+------------+-------+-----+-----+-----+----+----+----+----+----+----+

When function "menu_tree_page_data" gets a menu entry for the current page just gets the first result. Reverse ordering the query by depth will return the deepest menu entry first and the menu will be rendered correctly.

The attached patch adds the ordering to the query.

Comments

plach’s picture

Version: 6.4 » 6.x-dev
Status: Active » Reviewed & tested by the community

The patch works as advertised.

pwolanin’s picture

Version: 6.x-dev » 7.x-dev
Status: Reviewed & tested by the community » Needs review

I agree it's a bug not to have some ORDER BY set, to resolve multiple links. It's not clear to be if either depth ASC or depth DESC is correct.

Also, all bugs must be fixed in HEAD first.

plach’s picture

StatusFileSize
new15.09 KB
new17.92 KB
new15.71 KB
new2.32 KB

@pwolanin:

It's not clear to be if either depth ASC or depth DESC is correct.

After thinking about this some more I ain't sure that selecting just one row is the way to go: consider the attached (pretty weird) use case in which the same node (node 2) is linked multiple times in two different subtrees: we need every parent to be selected. Hence we should use all the rows in the result set.

Edit: ignore the first attachment, it's a wrong image.

plach’s picture

Version: 7.x-dev » 8.x-dev
kscheirer’s picture

#3: menu-306412-3.patch queued for re-testing.

Status: Needs review » Needs work

The last submitted patch, menu-306412-3.patch, failed testing.

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.8.x-dev

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

pameeela’s picture

Status: Needs work » Closed (duplicate)
Issue tags: +Bug Smash Initiative
Related issues: +#732370: Go as deep as possible when building the active trail.

Closing this as a duplicate in favour of #732370: Go as deep as possible when building the active trail.. This issue is older but the other one has much more recent activity.