Index: includes/menu.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/menu.inc,v retrieving revision 1.341 diff -u -p -r1.341 menu.inc --- includes/menu.inc 24 Aug 2009 01:49:41 -0000 1.341 +++ includes/menu.inc 9 Sep 2009 03:47:47 -0000 @@ -2190,26 +2190,15 @@ function menu_link_save(&$item) { } } - if (isset($item['plid'])) { - if ($item['plid']) { - $parent = db_query("SELECT * FROM {menu_links} WHERE mlid = :mlid", array(':mlid' => $item['plid']))->fetchAssoc(); - } - else { - // Don't bother with the query - mlid can never equal zero.. - $parent = FALSE; - } - } - else { $query = db_select('menu_links'); // Only links derived from router items should have module == 'system', and // we want to find the parent even if it's in a different menu. - if ($item['module'] == 'system') { - $query->condition('module', 'system'); - } - else { - // If not derived from a router item, we respect the specified menu name. + if (!$item['customized']) { $query->condition('menu_name', $item['menu_name']); } + elseif ($item['module'] == 'system') { + $query->condition('module', 'system'); + } // Find the parent - it must be unique. $parent_path = $item['link_path']; @@ -2223,7 +2212,7 @@ function menu_link_save(&$item) { $parent = $new_query->fields('menu_links')->execute()->fetchAssoc(); } } while ($parent === FALSE && $parent_path); - } + if ($parent !== FALSE) { $item['menu_name'] = $parent['menu_name']; } @@ -2673,8 +2662,17 @@ function _menu_router_build($callbacks) $parent_path = implode('/', array_slice($item['_parts'], 0, $i)); if (isset($menu[$parent_path])) { - $parent = $menu[$parent_path]; + $parent = &$menu[$parent_path]; + if (!isset($item['menu_name'])) { + if (!isset($parent['menu_name'])) { + $parent['menu_name'] = db_query("SELECT menu_name FROM {menu_links} WHERE router_path = :router_path", array(':router_path' => $parent_path))->fetchColumn(); + } + if ($parent['menu_name']) { + // Parent stores the parent of the path. + $item['menu_name'] = $parent['menu_name']; + } + } if (!isset($item['tab_parent'])) { // Parent stores the parent of the path. $item['tab_parent'] = $parent_path;