diff --git a/core/includes/update.inc b/core/includes/update.inc index 5582bb4..6794ca7 100644 --- a/core/includes/update.inc +++ b/core/includes/update.inc @@ -578,6 +578,11 @@ function update_batch($start, $redirect = NULL, $url = NULL, $batch = array(), $ * @see update_batch() */ function update_finished($success, $results, $operations) { + // Unlock the module system to flush all caches. + module_list_reset(); + // Load all modules, so data structures can be properly rebuilt. + module_load_all(FALSE, TRUE); + // Clear the caches in case the data has been updated. drupal_flush_all_caches(); diff --git a/core/update.php b/core/update.php index 1a00777..35b42b4 100644 --- a/core/update.php +++ b/core/update.php @@ -129,6 +129,11 @@ function update_script_selection_form($form, &$form_state) { '#links' => update_helpful_links(), ); + // Unlock the module system to flush all caches. + module_list_reset(); + // Load all modules, so data structures can be properly rebuilt. + module_load_all(FALSE, TRUE); + // No updates to run, so caches won't get flushed later. Clear them now. drupal_flush_all_caches(); } @@ -375,9 +380,20 @@ function update_check_requirements($skip_warnings = FALSE) { require_once DRUPAL_ROOT . '/core/includes/unicode.inc'; require_once DRUPAL_ROOT . '/core/includes/schema.inc'; -// Limit the module list to System module for the entire duration of update.php. +// The module list must be limited to System module for almost all parts of the +// update process to prevent module APIs and hooks from being invoked too early +// (trying to act on data structures that are not updated yet). +// This especially applies to early bootstrap preparations when upgrading to a +// new major version of Drupal core. Unfortunately, however, the initial +// information and update selection pages (and forms) need to be able to invoke +// hook_requirements() in all modules and also access other APIs. Therefore, the +// effective module list has to be switched back and forth multiple times during +// the update.php process. include_once DRUPAL_ROOT . '/core/includes/module.inc'; $module_list['system']['filename'] = 'core/modules/system/system.module'; + +// Lock the module list for the update bootstrap and performing initial system +// changes. module_list(NULL, $module_list); update_prepare_d8_bootstrap(); @@ -418,6 +434,9 @@ function update_check_requirements($skip_warnings = FALSE) { // Set up theme system for the maintenance page. drupal_maintenance_theme(); + // Unlock the module system to perform update requirements checks. + module_list_reset(); + // Check the update requirements for Drupal. Only report on errors at this // stage, since the real requirements check happens further down. update_check_requirements(TRUE); @@ -447,6 +466,9 @@ function update_check_requirements($skip_warnings = FALSE) { update_fix_compatibility(); + // Unlock the module system to perform update requirements checks. + module_list_reset(); + // Check the update requirements for all modules. If there are warnings, but // no errors, skip reporting them if the user has provided a URL parameter // acknowledging the warnings and indicating a desire to continue anyway. See @@ -455,6 +477,9 @@ function update_check_requirements($skip_warnings = FALSE) { $skip_warnings = !empty($continue); update_check_requirements($skip_warnings); + // Re-lock the module system. + module_list(NULL, $module_list); + switch ($op) { // update.php ops. @@ -482,6 +507,11 @@ function update_check_requirements($skip_warnings = FALSE) { break; case 'results': + // Unlock the module system after performing updates. + module_list_reset(); + // Load all modules to flush all caches and rebuild data structures. + module_load_all(FALSE, TRUE); + $output = update_results_page(); break;