diff -u b/core/includes/common.inc b/core/includes/common.inc --- b/core/includes/common.inc +++ b/core/includes/common.inc @@ -7379,6 +7379,14 @@ // Important: This rebuild must happen last, so the menu router is guaranteed // to be based on up to date information. menu_rebuild(); + + // Re-initialize the maintenance theme, if the current request attempted to + // use it. Unlike regular usages of this function, the installer and update + // scripts need to flush all caches during GET requests/page building. + if (function_exists('_drupal_maintenance_theme')) { + unset($GLOBALS['theme']); + drupal_maintenance_theme(); + } } /** diff -u b/core/includes/install.core.inc b/core/includes/install.core.inc --- b/core/includes/install.core.inc +++ b/core/includes/install.core.inc @@ -1526,7 +1526,7 @@ // Add JS to show / hide the 'Email administrator about site updates' elements drupal_add_js('jQuery(function () { Drupal.hideEmailAdministratorCheckbox() });', 'inline'); // Build menu to allow clean URL check. - menu_rebuild(); + menu_router_rebuild(); // Cache a fully-built schema. This is necessary for any invocation of // index.php because: (1) setting cache table entries requires schema @@ -1586,11 +1586,6 @@ // registered by the install profile are registered correctly. drupal_flush_all_caches(); - // Re-initialize the maintenance theme for the final installation page. - // @see drupal_flush_all_caches() - unset($GLOBALS['theme']); - drupal_maintenance_theme(); - drupal_set_title(st('@drupal installation complete', array('@drupal' => drupal_install_profile_distribution_name())), PASS_THROUGH); $messages = drupal_set_message(); diff -u b/core/modules/simpletest/drupal_web_test_case.php b/core/modules/simpletest/drupal_web_test_case.php --- b/core/modules/simpletest/drupal_web_test_case.php +++ b/core/modules/simpletest/drupal_web_test_case.php @@ -1014,7 +1014,7 @@ $saved_type = node_type_save($type); node_types_rebuild(); - menu_rebuild(); + menu_router_rebuild(); node_add_body_field($type); $this->assertEqual($saved_type, SAVED_NEW, t('Created content type %type.', array('%type' => $type->type))); diff -u b/core/modules/system/system.test b/core/modules/system/system.test --- b/core/modules/system/system.test +++ b/core/modules/system/system.test @@ -2184,7 +2184,7 @@ // Enable our test module. Flush all caches, which we assert is the only // thing necessary to use the rebuilt {system}.info. module_enable(array('module_test'), FALSE); - drupal_flush_all_caches(); + $this->resetAll(); $this->assertTrue(module_exists('module_test'), t('Test module is enabled.')); $info = $this->getSystemInfo('seven', 'theme'); @@ -2199,7 +2199,7 @@ // Disable the module and verify that {system}.info is rebuilt without it. module_disable(array('module_test'), FALSE); - drupal_flush_all_caches(); + $this->resetAll(); $this->assertFalse(module_exists('module_test'), t('Test module is disabled.')); $info = $this->getSystemInfo('seven', 'theme'); only in patch2: unchanged: --- a/core/includes/gettext.inc +++ b/core/includes/gettext.inc @@ -61,7 +61,7 @@ function _locale_import_po($file, $langcode, $overwrite_options, $customized = L cache()->deletePrefix('locale:'); // Rebuild the menu, strings may have changed. - menu_rebuild(); + menu_router_rebuild(); drupal_set_message(t('The translation was successfully imported. There are %number newly created translated strings, %update strings were updated and %delete strings were removed.', array('%number' => $additions, '%update' => $updates, '%delete' => $deletes))); watchdog('locale', 'Imported %file into %locale: %number new strings added, %update updated and %delete removed.', array('%file' => $file->filename, '%locale' => $langcode, '%number' => $additions, '%update' => $updates, '%delete' => $deletes)); only in patch2: unchanged: --- a/core/includes/lock.inc +++ b/core/includes/lock.inc @@ -13,9 +13,10 @@ * In most environments, multiple Drupal page requests (a.k.a. threads or * processes) will execute in parallel. This leads to potential conflicts or * race conditions when two requests execute the same code at the same time. A - * common example of this is a rebuild like menu_rebuild() where we invoke many - * hook implementations to get and process data from all active modules, and - * then delete the current data in the database to insert the new afterwards. + * common example of this is a rebuild like menu_router_rebuild() where we + * invoke many hook implementations to get and process data from all active + * modules, and then delete the current data in the database to insert the new + * afterwards. * * This is a cooperative, advisory lock system. Any long-running operation * that could potentially be attempted in parallel by multiple requests should only in patch2: unchanged: --- a/core/includes/menu.inc +++ b/core/includes/menu.inc @@ -301,7 +301,7 @@ const MENU_PREFERRED_LINK = '1cf698d64d1aa4b83907cf6ed55db3a7f8e92c91'; * then the 1011 bitstring represents node/%/edit/foo where % means that * any argument matches that part. We limit ourselves to using binary * numbers that correspond the patterns of wildcards of router items that - * actually exists. This list of 'masks' is built in menu_rebuild(). + * actually exists. This list of 'masks' is built in menu_router_rebuild(). * * @param $parts * An array of path parts, for the above example @@ -450,7 +450,7 @@ function menu_get_item($path = NULL, $router_item = NULL) { // Rebuild if we know it's needed, or if the menu masks are missing which // occurs rarely, likely due to a race condition of multiple rebuilds. if (variable_get('menu_rebuild_needed', FALSE) || !variable_get('menu_masks', array())) { - menu_rebuild(); + menu_router_rebuild(); } $original_map = arg(NULL, $path); @@ -2657,12 +2657,12 @@ function menu_reset_static_cache() { * TRUE if the menu was rebuilt, FALSE if another thread was rebuilding * in parallel and the current thread just waited for completion. */ -function menu_rebuild() { - if (!lock_acquire('menu_rebuild')) { +function menu_router_rebuild() { + if (!lock_acquire(__FUNCTION__)) { // Wait for another request that is already doing this work. // We choose to block here since otherwise the router item may not // be available in menu_execute_active_handler() resulting in a 404. - lock_wait('menu_rebuild'); + lock_wait(__FUNCTION__); return FALSE; } @@ -2683,7 +2683,7 @@ function menu_rebuild() { watchdog_exception('menu', $e); } - lock_release('menu_rebuild'); + lock_release(__FUNCTION__); return TRUE; } only in patch2: unchanged: --- a/core/includes/theme.inc +++ b/core/includes/theme.inc @@ -1489,7 +1489,7 @@ function theme_enable($theme_list) { } list_themes(TRUE); - menu_rebuild(); + menu_router_rebuild(); drupal_theme_rebuild(); // Invoke hook_themes_enabled() after the themes have been enabled. @@ -1522,7 +1522,7 @@ function theme_disable($theme_list) { } list_themes(TRUE); - menu_rebuild(); + menu_router_rebuild(); drupal_theme_rebuild(); // Invoke hook_themes_disabled after the themes have been disabled. only in patch2: unchanged: --- a/core/modules/aggregator/aggregator.test +++ b/core/modules/aggregator/aggregator.test @@ -893,7 +893,7 @@ class AggregatorRenderingTestCase extends AggregatorTestCase { $feed->block = 0; aggregator_save_feed((array) $feed); // It is nescessary to flush the cache after saving the number of items. - drupal_flush_all_caches(); + $this->resetAll(); // Check that the block is no longer displayed. $this->drupalGet('node'); $this->assertNoText(t($block['title']), 'Feed block is not displayed on the page when number of items is set to 0.'); only in patch2: unchanged: --- a/core/modules/block/block.test +++ b/core/modules/block/block.test @@ -391,7 +391,7 @@ class BlockTestCase extends DrupalWebTestCase { // Disable caching for this block. variable_set('block_test_caching', DRUPAL_NO_CACHE); // Flushing all caches should call _block_rehash(). - drupal_flush_all_caches(); + $this->resetAll(); // Verify that the database is updated with the new caching mode. $current_caching = db_query("SELECT cache FROM {block} WHERE module = 'block_test' AND delta = 'test_cache'")->fetchField(); $this->assertEqual($current_caching, DRUPAL_NO_CACHE, t("Test block's database entry updated to DRUPAL_NO_CACHE.")); @@ -833,7 +833,7 @@ class BlockHiddenRegionTestCase extends DrupalWebTestCase { $theme = 'block_test_theme'; theme_enable(array($theme)); variable_set('theme_default', $theme); - menu_rebuild(); + menu_router_rebuild(); // Ensure that "block_test_theme" is set as the default theme. $this->drupalGet('admin/structure/block'); only in patch2: unchanged: --- a/core/modules/entity/tests/entity.test +++ b/core/modules/entity/tests/entity.test @@ -222,7 +222,7 @@ class EntityAPIInfoTestCase extends DrupalWebTestCase { // Change the label of the test entity type and make sure changes appear // after flushing caches. variable_set('entity_cache_test_label', 'New label.'); - drupal_flush_all_caches(); + $this->resetAll(); $info = entity_get_info('entity_cache_test'); $this->assertEqual($info['label'], 'New label.', 'New label appears in entity info.'); only in patch2: unchanged: --- a/core/modules/field_ui/field_ui.module +++ b/core/modules/field_ui/field_ui.module @@ -52,7 +52,7 @@ function field_ui_help($path, $arg) { function field_ui_field_attach_rename_bundle($entity_type, $bundle_old, $bundle_new) { // The Field UI relies on entity_get_info() to build menu items for entity // field administration pages. Ensure that the menu is rebuilt. - menu_rebuild(); + menu_router_rebuild(); } /** only in patch2: unchanged: --- a/core/modules/menu/menu.install +++ b/core/modules/menu/menu.install @@ -66,6 +66,6 @@ function menu_install() { * Implements hook_uninstall(). */ function menu_uninstall() { - menu_rebuild(); + menu_router_rebuild(); } only in patch2: unchanged: --- a/core/modules/menu/menu.module +++ b/core/modules/menu/menu.module @@ -180,7 +180,7 @@ function menu_theme() { * Add a link for each custom menu. */ function menu_enable() { - menu_rebuild(); + menu_router_rebuild(); $base_link = db_query("SELECT mlid AS plid, menu_name FROM {menu_links} WHERE link_path = 'admin/structure/menu' AND module = 'system'")->fetchAssoc(); $base_link['router_path'] = 'admin/structure/menu/manage/%'; $base_link['module'] = 'menu'; only in patch2: unchanged: --- a/core/modules/node/content_types.inc +++ b/core/modules/node/content_types.inc @@ -355,7 +355,7 @@ function node_type_form_submit($form, &$form_state) { $status = node_type_save($type); node_types_rebuild(); - menu_rebuild(); + menu_router_rebuild(); $t_args = array('%name' => $type->name); if ($status == SAVED_UPDATED) { @@ -458,7 +458,7 @@ function node_type_delete_confirm_submit($form, &$form_state) { watchdog('menu', 'Deleted content type %name.', $t_args, WATCHDOG_NOTICE); node_types_rebuild(); - menu_rebuild(); + menu_router_rebuild(); $form_state['redirect'] = 'admin/structure/types'; return; only in patch2: unchanged: --- a/core/modules/search/search.test +++ b/core/modules/search/search.test @@ -1225,7 +1225,7 @@ class SearchKeywordsConditions extends SearchWebTestCase { $this->drupalLogin($this->searching_user); // Test with all search modules enabled. variable_set('search_active_modules', array('node' => 'node', 'user' => 'user', 'search_extra_type' => 'search_extra_type')); - menu_rebuild(); + menu_router_rebuild(); } /** @@ -1936,7 +1936,7 @@ class SearchPageOverride extends SearchWebTestCase { // Enable the extra type module for searching. variable_set('search_active_modules', array('node' => 'node', 'user' => 'user', 'search_extra_type' => 'search_extra_type')); - menu_rebuild(); + menu_router_rebuild(); } function testSearchPageHook() { only in patch2: unchanged: --- a/core/modules/shortcut/shortcut.install +++ b/core/modules/shortcut/shortcut.install @@ -36,7 +36,7 @@ function shortcut_install() { // Drupal is already installed (i.e., we are not in the installer). // @see http://drupal.org/node/1376150 if (variable_get('install_task', '') != 'done') { - menu_rebuild(); + menu_router_rebuild(); } shortcut_set_save($shortcut_set); } only in patch2: unchanged: --- a/core/modules/system/system.admin.inc +++ b/core/modules/system/system.admin.inc @@ -327,12 +327,13 @@ function system_theme_default() { // Set the default theme. variable_set('theme_default', $theme); - // Rebuild the menu. This duplicates the menu_rebuild() in theme_enable(). - // However, modules must know the current default theme in order to use - // this information in hook_menu() or hook_menu_alter() implementations, - // and doing the variable_set() before the theme_enable() could result - // in a race condition where the theme is default but not enabled. - menu_rebuild(); + // Rebuild the menu. This duplicates the menu_router_rebuild() in + // theme_enable(). However, modules must know the current default theme in + // order to use this information in hook_menu() or hook_menu_alter() + // implementations, and doing the variable_set() before the theme_enable() + // could result in a race condition where the theme is default but not + // enabled. + menu_router_rebuild(); // The status message depends on whether an admin theme is currently in use: // a value of 0 means the admin theme is set to be the default theme. only in patch2: unchanged: --- a/core/modules/system/tests/menu.test +++ b/core/modules/system/tests/menu.test @@ -395,7 +395,7 @@ class MenuRouterTestCase extends DrupalWebTestCase { // Change the menu_name parameter in menu_test.module, then force a menu // rebuild. menu_test_menu_name('changed'); - menu_rebuild(); + menu_router_rebuild(); $sql = "SELECT menu_name FROM {menu_links} WHERE router_path = 'menu_name_test'"; $name = db_query($sql)->fetchField();