When a particular menu is set as the default for a content type, and a node of that type is edited, Drupal is supposed to select a menu entry from that menu in preference to other menu links to the node:

      // Give priority to the default menu
      $mlid = db_query_range("SELECT mlid FROM {menu_links} WHERE link_path = :path AND menu_name = :menu_name AND module = 'menu' ORDER BY mlid ASC", 0, 1, array(
        ':path' => 'node/' . $node->nid,
        ':menu_name' => $menu_name,
      ))->fetchField();

The problem is that $menu_name contains a menu option 'main-menu:0' not a menu name 'main-menu'. This issue also impacts the default values that are provided, including new nodes.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

lyricnz’s picture

Status: Active » Needs review
FileSize
699 bytes

Patch

sun’s picture

Status: Needs review » Needs work
+++ b/modules/menu/menu.module
@@ -540,7 +540,9 @@ function menu_node_delete($node) {
+    preg_match('/^(.*):[0-9]+$/', $menu_parent, $matches);
+    $menu_name = $matches[1];

$menu_name = explode(':' $menu_name);
$menu_name = $menu_name[0];

cuts it.

Powered by Dreditor.

sun’s picture

Even better yet:

$menu_name = strtok($menu_name, ':');

lyricnz’s picture

Status: Needs work » Needs review
FileSize
619 bytes

Thanks, Updated to use strtok().

lyricnz’s picture

Status: Needs review » Closed (duplicate)