In #273137: Split Navigation to User and Administration menu I found a bug in function _menu_navigation_links_rebuild() that prevented any menu links except those at the very top level form being parented/re-parented to the correct menu via a specification in hook_menu.

Here's the 7.x fix, which needs to be backported to 6.x:

@@ -1863,7 +1880,6 @@ function _menu_navigation_links_rebuild(
   $menu_links = array();
   foreach ($menu as $path => $item) {
     if ($item['_visible']) {
-      $item = _menu_link_build($item);
       $menu_links[$path] = $item;
       $sort[$path] = $item['_number_parts'];
     }
@@ -1882,7 +1898,7 @@ function _menu_navigation_links_rebuild(
           'has_children',
           'updated',
         ))
-        ->condition('link_path', $item['link_path'])
+        ->condition('link_path', $item['path'])
         ->condition('module', 'system')
         ->execute()->fetchAssoc();
       if ($existing_item) {
@@ -1892,17 +1908,22 @@ function _menu_navigation_links_rebuild(
           $item['menu_name'] = $existing_item['menu_name'];
           $item['plid'] = $existing_item['plid'];
         }
+        else {
+          // If it moved, put it at the top level in the new menu.
+          $item['plid'] = 0;
+        }
         $item['has_children'] = $existing_item['has_children'];
         $item['updated'] = $existing_item['updated'];
       }
       if (!$existing_item || !$existing_item['customized']) {
+        $item = _menu_link_build($item);
         menu_link_save($item);
       }
     }
   }
Files: 
CommentFileSizeAuthor
#6 system-links-408338-6-D7.patch3.38 KBpwolanin
Failed: 10667 passes, 18 fails, 0 exceptions
[ View ]
#1 navigation-links-408338-1.patch1.87 KBpwolanin
Failed: Failed to apply patch.
[ View ]

Comments

Status:Active» Needs review
StatusFileSize
new1.87 KB
Failed: Failed to apply patch.
[ View ]

Direct back-port.

Straight backport, code looks fine, can't be tested directly in core but it's already in D7, so RTBC.

Status:Needs review» Reviewed & tested by the community

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

I tested more last night (and dreamed about this code) and I relize now that it's only (now) working more-or-less right when going form the default menu (empty menu_nam attribute in hook_menu) to some other menu. But, it does not work right in the reverse direction.

Title:back-port _menu_navigation_links_rebuild fix to 6.xfix_menu_navigation_links_rebuild to correctly handle changing menu_name

StatusFileSize
new3.38 KB
Failed: 10667 passes, 18 fails, 0 exceptions
[ View ]

Status:Needs work» Needs review

Status:Needs review» Needs work

The last submitted patch failed testing.

hmm, something is not right indeed. Move links out of the admin section.