Index: includes/menu.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/menu.inc,v
retrieving revision 1.383
diff -u -p -r1.383 menu.inc
--- includes/menu.inc	26 Mar 2010 17:14:45 -0000	1.383
+++ includes/menu.inc	28 Mar 2010 01:39:50 -0000
@@ -2644,18 +2644,17 @@ function menu_link_save(&$item) {
     }
   }
 
-  // If we have a parent link ID, we use it to inherit 'menu_name' and 'depth'.
+  // If this link defines a parent link id, try to find it in the current menu
+  // links. If found, we use it for the re-parenting process below. This parent
+  // link validation also needs to be done for links specifying a plid of 0
+  // (zero), since {menu_links} may contain stale/bogus data caused by a
+  // re-parenting process that went wrong in a previous rebuild.
   if (isset($item['plid'])) {
-    if ($item['plid']) {
-      $parent = db_query("SELECT * FROM {menu_links} WHERE mlid = :mlid", array(':mlid' => $item['plid']))->fetchAssoc();
-    }
-    // If the parent link ID is zero, then this link lives at the top-level.
-    else {
-      $parent = FALSE;
-    }
+    $parent = db_query("SELECT * FROM {menu_links} WHERE mlid = :mlid", array(':mlid' => $item['plid']))->fetchAssoc();
   }
-  // Otherwise, try to find a valid parent link for this link.
-  else {
+  // If no plid was specified or it was not found, try to find a new, valid
+  // parent link for this link.
+  if (empty($parent)) {
     $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.
