Index: includes/menu.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/menu.inc,v retrieving revision 1.269 diff -u -p -r1.269 menu.inc --- includes/menu.inc 23 Apr 2008 20:01:47 -0000 1.269 +++ includes/menu.inc 3 May 2008 00:39:19 -0000 @@ -1658,7 +1658,6 @@ function menu_router_build($reset = FALS $menu = $cache->data; } else { - db_query('DELETE FROM {menu_router}'); // We need to manually call each module so that we can know which module // a given item came from. $callbacks = array(); @@ -1674,7 +1673,6 @@ function menu_router_build($reset = FALS // Alter the menu as defined in modules, keys are like user/%user. drupal_alter('menu', $callbacks); $menu = _menu_router_build($callbacks); - cache_set('router:', $menu, 'cache_menu'); } } return $menu; @@ -2254,6 +2252,14 @@ function _menu_router_build($callbacks) } array_multisort($sort, SORT_NUMERIC, $menu); + if (!$menu) { + // We must have a serious error - there is no data to save. + watchdog('php', 'Menu router rebuild failed - some paths may not work correctly.', array(), WATCHDOG_ERROR); + return array(); + } + // Delete the existing router since we have some data to replace it. + db_lock_table('menu_router'); + db_query('DELETE FROM {menu_router}'); // Apply inheritance rules. foreach ($menu as $path => $v) { $item = &$menu[$path]; @@ -2352,10 +2358,12 @@ function _menu_router_build($callbacks) $item['title'], $item['title callback'], $title_arguments, $item['type'], $item['block callback'], $item['description'], $item['position'], $item['weight'], $item['include file']); } + db_unlock_tables(); // Sort the masks so they are in order of descending fit, and store them. $masks = array_keys($masks); rsort($masks); variable_set('menu_masks', $masks); + cache_set('router:', $menu, 'cache_menu'); return $menu; }