From 9ecd0e522a2b718c23a32d3c800ba0b065a081e2 Mon Sep 17 00:00:00 2001
From: Dries Buytaert <dries@buytaert.net>
Date: Tue, 12 Apr 2011 22:42:29 +0200
Subject: [PATCH] - Patch #997918 by David_Rothstein: menu gets rebuilt
 continually during install and update (and menu system stores entire,
 out-of-date theme objects).

---
 includes/menu.inc                | 14 +++-----------
 modules/block/block.module       |  4 ++--
 modules/field_ui/field_ui.module |  6 ------
 modules/system/system.module     |  4 ++--
 4 files changed, 7 insertions(+), 21 deletions(-)

diff --git a/includes/menu.inc b/includes/menu.inc
index 007e4a2b9e85..f510146c0234 100644
--- a/includes/menu.inc
+++ b/includes/menu.inc
@@ -2566,10 +2566,7 @@ function menu_reset_static_cache() {
  *
  * This function will clear and populate the {menu_router} table, add entries
  * to {menu_links} for new router items, then remove stale items from
- * {menu_links}. If called from update.php or install.php, it will also
- * schedule a call to itself on the first real page load from
- * menu_execute_active_handler(), because the maintenance page environment
- * is different and leaves stale data in the menu tables.
+ * {menu_links}.
  *
  * @return
  *   TRUE if the menu was rebuilt, FALSE if another thread was rebuilding
@@ -2593,13 +2590,8 @@ function menu_rebuild() {
     // Clear the menu, page and block caches.
     menu_cache_clear_all();
     _menu_clear_page_cache();
-
-    if (defined('MAINTENANCE_MODE')) {
-      variable_set('menu_rebuild_needed', TRUE);
-    }
-    else {
-      variable_del('menu_rebuild_needed');
-    }
+    // Indicate that the menu has been successfully rebuilt.
+    variable_del('menu_rebuild_needed');
   }
   catch (Exception $e) {
     $transaction->rollback();
diff --git a/modules/block/block.module b/modules/block/block.module
index 7790600f16fa..c5e229bb8ca1 100644
--- a/modules/block/block.module
+++ b/modules/block/block.module
@@ -148,7 +148,7 @@ function block_menu() {
       'type' => $key == $default_theme ? MENU_DEFAULT_LOCAL_TASK : MENU_LOCAL_TASK,
       'weight' => $key == $default_theme ? -10 : 0,
       'access callback' => '_block_themes_access',
-      'access arguments' => array($theme),
+      'access arguments' => array($key),
       'file' => 'block.admin.inc',
     );
     if ($key != $default_theme) {
@@ -167,7 +167,7 @@ function block_menu() {
       'page arguments' => array($key),
       'type' => MENU_CALLBACK,
       'access callback' => '_block_themes_access',
-      'access arguments' => array($theme),
+      'access arguments' => array($key),
       'theme callback' => '_block_custom_theme',
       'theme arguments' => array($key),
       'file' => 'block.admin.inc',
diff --git a/modules/field_ui/field_ui.module b/modules/field_ui/field_ui.module
index 59b2beb6644b..28ac0e1d351d 100644
--- a/modules/field_ui/field_ui.module
+++ b/modules/field_ui/field_ui.module
@@ -60,12 +60,6 @@ function field_ui_menu() {
     'file' => 'field_ui.admin.inc',
   );
 
-  // Ensure the following is not executed until field_bundles is working and
-  // tables are updated. Needed to avoid errors on initial installation.
-  if (defined('MAINTENANCE_MODE')) {
-    return $items;
-  }
-
   // Create tabs for all possible bundles.
   foreach (entity_get_info() as $entity_type => $entity_info) {
     if ($entity_info['fieldable']) {
diff --git a/modules/system/system.module b/modules/system/system.module
index 5af9ad4ee1be..21b23f4c223e 100644
--- a/modules/system/system.module
+++ b/modules/system/system.module
@@ -635,13 +635,13 @@ function system_menu() {
     'weight' => -1,
   );
 
-  foreach (list_themes() as $theme) {
+  foreach (list_themes() as $key => $theme) {
     $items['admin/appearance/settings/' . $theme->name] = array(
       'title' => $theme->info['name'],
       'page arguments' => array('system_theme_settings', $theme->name),
       'type' => MENU_LOCAL_TASK,
       'access callback' => '_system_themes_access',
-      'access arguments' => array($theme),
+      'access arguments' => array($key),
       'file' => 'system.admin.inc',
     );
   }
-- 
GitLab