Index: includes/menu.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/menu.inc,v
retrieving revision 1.166
diff -u -p -r1.166 menu.inc
--- includes/menu.inc	16 May 2007 13:45:16 -0000	1.166
+++ includes/menu.inc	18 May 2007 16:55:40 -0000
@@ -149,11 +149,6 @@ define('MENU_SITE_OFFLINE', 4);
  * @} End of "Menu status codes".
  */
 
-
-/**
- * @} End of "Menu operations."
- */
-
 /**
  * @Name Menu tree parameters
  * @{
@@ -1004,9 +999,7 @@ function menu_get_active_title() {
 function menu_get_item_by_mlid($mlid) {
   if ($item = db_fetch_object(db_query("SELECT * FROM {menu_links} ml LEFT JOIN {menu_router} m ON m.path = ml.router_path WHERE mlid = %d", $mlid))) {
     _menu_link_translate($item);
-    if ($item->access) {
-      return $item;
-    }
+    return $item;
   }
   return FALSE;
 }
@@ -1074,11 +1067,13 @@ function _menu_navigation_links_rebuild(
     if ($item['type'] == MENU_CALLBACK || $item['type'] == MENU_SUGGESTED_ITEM) {
       $item['hidden'] = $item['type'];
     }
+    // Note, we set this as 'system', so that we can be sure to distinguish all
+    // the menu links generated automatically from entries in {menu_router}.
+    $item['module'] = 'system';
     $item += array(
       'menu name' => 'navigation',
       'link_title' => $item['title'],
       'href' => $path,
-      'module' => 'system',
       'hidden' => 0,
     );
     // We add nonexisting items.
@@ -1188,7 +1183,7 @@ function menu_link_save(&$item, $_menu =
     $item['p'. $item['depth']] = $item['mlid'];
   }
 
-  if ($item['plid'] != $existing_item['plid']) {
+  if (!empty($existing_item) && ($item['plid'] != $existing_item['plid'])) {
 
     // TODO: UPDATE the parents of the children of the current item
     // TODO: check the has_children status of the previous parent
