diff --git a/core/includes/bootstrap.inc b/core/includes/bootstrap.inc index ca45730..3f2f591 100644 --- a/core/includes/bootstrap.inc +++ b/core/includes/bootstrap.inc @@ -1453,7 +1453,7 @@ function t($string, array $args = array(), array $options = array()) { $locale_exists = &drupal_static(__FUNCTION__); if (!isset($locale_exits)) { - $locale_exists = module_exists('locale'); + $locale_exists = function_exists('module_exists') && module_exists('locale'); } // Merge in default. diff --git a/core/includes/module.inc b/core/includes/module.inc index a772436..db1947d 100644 --- a/core/includes/module.inc +++ b/core/includes/module.inc @@ -11,26 +11,30 @@ /** * Loads all the modules that have been enabled in the system table. * - * @param $bootstrap + * @param bool $bootstrap * Whether to load only the reduced set of modules loaded in "bootstrap mode" - * for cached pages. See bootstrap.inc. + * for cached pages. See bootstrap.inc. Pass NULL to only check the current + * status without loading of modules. + * @param bool $reset + * (optional) Internal use only. Whether to reset the internal statically + * cached flag of whether modules have been loaded. If TRUE, all modules are + * (re)loaded in the same call. Used by the testing framework to override and + * persist a limited module list for the duration of a unit test (in which no + * module system exists). * - * @return - * If $bootstrap is NULL, return a boolean indicating whether all modules - * have been loaded. + * @return bool + * A Boolean indicating whether all modules have been loaded. This means all + * modules; the load status of bootstrap modules cannot be checked. */ -function module_load_all($bootstrap = FALSE) { - // Already loaded code cannot be unloaded, but new modules may be added within - // a request, which should be loaded as well. - // Use the advanced drupal_static() pattern, since this is called very often. - // @see theme() - static $drupal_static_fast; - if (!isset($drupal_static_fast)) { - $drupal_static_fast['has_run'] = &drupal_static(__FUNCTION__, FALSE); +function module_load_all($bootstrap = FALSE, $reset = FALSE) { + static $has_run = FALSE; + + if ($reset) { + $has_run = FALSE; } - $has_run = &$drupal_static_fast['has_run']; - if (isset($bootstrap)) { + // Unless $boostrap is NULL, load the requested set of modules. + if (isset($bootstrap) && !$has_run) { $type = $bootstrap ? 'bootstrap' : 'module_enabled'; foreach (module_list($type) as $module) { drupal_load('module', $module); diff --git a/core/modules/field/modules/field_sql_storage/field_sql_storage.install b/core/modules/field/modules/field_sql_storage/field_sql_storage.install index 2229ef4..0bbdc5a 100644 --- a/core/modules/field/modules/field_sql_storage/field_sql_storage.install +++ b/core/modules/field/modules/field_sql_storage/field_sql_storage.install @@ -111,6 +111,9 @@ function field_sql_storage_update_8000(&$sandbox) { // Retrieve field data. $fields = _update_7000_field_read_fields(array('storage_type' => 'field_sql_storage')); + // Load private table name helper functions in field_sql_storage.module. + drupal_load('module', 'field_sql_storage'); + // Update schema. foreach ($fields as $field) { $data_table = _field_sql_storage_tablename($field); diff --git a/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php index 00eb07f..048da36 100644 --- a/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php +++ b/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php @@ -796,8 +796,9 @@ protected function tearDown() { // Reset all static variables. drupal_static_reset(); - // Reset module list. + // Reset module list and module load status. module_list_reset(); + module_load_all(FALSE, TRUE); // Restore original in-memory configuration. $conf = $this->originalConf; diff --git a/core/modules/system/lib/Drupal/system/Tests/Upgrade/UpgradePathTestBase.php b/core/modules/system/lib/Drupal/system/Tests/Upgrade/UpgradePathTestBase.php index a0f6c59..86456e5 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Upgrade/UpgradePathTestBase.php +++ b/core/modules/system/lib/Drupal/system/Tests/Upgrade/UpgradePathTestBase.php @@ -191,13 +191,13 @@ protected function performUpgrade($register_errors = TRUE) { $update_url = $GLOBALS['base_url'] . '/core/update.php'; $this->drupalGet($update_url, array('external' => TRUE)); if (!$this->assertResponse(200)) { - return FALSE; + throw new Exception('Initial GET to update.php did not return HTTP 200 status.'); } // Continue. $this->drupalPost(NULL, array(), t('Continue')); if (!$this->assertResponse(200)) { - return FALSE; + throw new Exception('POST to continue update.php did not return HTTP 200 status.'); } // The test should pass if there are no pending updates. @@ -211,7 +211,7 @@ protected function performUpgrade($register_errors = TRUE) { // Go! $this->drupalPost(NULL, array(), t('Apply pending updates')); if (!$this->assertResponse(200)) { - return FALSE; + throw new Exception('POST to update.php to apply pending updates did not return HTTP 200 status.'); } // Check for errors during the update process. @@ -222,36 +222,30 @@ protected function performUpgrade($register_errors = TRUE) { $this->fail($message); } } - if (!empty($this->upgradeErrors)) { // Upgrade failed, the installation might be in an inconsistent state, // don't process. - return FALSE; + throw new Exception('Errors during update process.'); } // Check if there still are pending updates. $this->drupalGet($update_url, array('external' => TRUE)); $this->drupalPost(NULL, array(), t('Continue')); if (!$this->assertText(t('No pending updates.'), t('No pending updates at the end of the update process.'))) { - return FALSE; + throw new Exception('update.php still shows pending updates after execution.'); } // Upgrade succeed, rebuild the environment so that we can call the API // of the child site directly from this request. $this->upgradedSite = TRUE; - // Reload module list. For modules that are enabled in the test database, - // but not on the test client, we need to load the code here. + // Reload module list for modules that are enabled in the test database + // but not on the test client. system_list_reset(); - foreach (module_list() as $module) { - drupal_load('module', $module); - } - - // Reload hook implementations module_implements_reset(); + module_load_all(FALSE, TRUE); // Rebuild caches. - drupal_static_reset(); drupal_flush_all_caches(); // Reload global $conf array and permissions. diff --git a/core/modules/user/user.install b/core/modules/user/user.install index 67957da..a22b2d8 100644 --- a/core/modules/user/user.install +++ b/core/modules/user/user.install @@ -351,11 +351,11 @@ function user_install() { * The 'Member for' extra field has moved one level up in the array. */ function user_update_8000() { - $settings = field_bundle_settings('user', 'user'); + $settings = update_variable_get('field_bundle_settings_user__user', array()); if (isset($settings['extra_fields']['display']['summary'])) { $settings['extra_fields']['display']['member_for'] = $settings['extra_fields']['display']['summary']; unset($settings['extra_fields']['display']['summary']); - field_bundle_settings('user', 'user', $settings); + update_variable_set('field_bundle_settings_user__user', $settings); } } diff --git a/core/update.php b/core/update.php index b8a726d..1a00777 100644 --- a/core/update.php +++ b/core/update.php @@ -366,10 +366,6 @@ function update_check_requirements($skip_warnings = FALSE) { } } -// Some unavoidable errors happen because the database is not yet up-to-date. -// Our custom error handler is not yet installed, so we just suppress them. -ini_set('display_errors', FALSE); - // We prepare a minimal bootstrap for the update requirements check to avoid // reaching the PHP memory limit. require_once DRUPAL_ROOT . '/core/includes/bootstrap.inc'; @@ -378,6 +374,12 @@ function update_check_requirements($skip_warnings = FALSE) { require_once DRUPAL_ROOT . '/core/includes/file.inc'; 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. +include_once DRUPAL_ROOT . '/core/includes/module.inc'; +$module_list['system']['filename'] = 'core/modules/system/system.module'; +module_list(NULL, $module_list); + update_prepare_d8_bootstrap(); // Determine if the current user has access to run update.php. @@ -404,9 +406,6 @@ function update_check_requirements($skip_warnings = FALSE) { require_once DRUPAL_ROOT . '/core/modules/system/system.install'; // Load module basics. - include_once DRUPAL_ROOT . '/core/includes/module.inc'; - $module_list['system']['filename'] = 'core/modules/system/system.module'; - module_list(NULL, $module_list); drupal_load('module', 'system'); // Reset the module_implements() cache so that any new hook implementations