diff --git a/core/includes/schema.inc b/core/includes/schema.inc index 4712d3be10e..aa3984b91ac 100644 --- a/core/includes/schema.inc +++ b/core/includes/schema.inc @@ -74,7 +74,7 @@ function drupal_get_schema_versions($module) { * module is not installed. */ function drupal_get_installed_schema_version($module, $reset = FALSE, $array = FALSE) { - static $versions = array(); + $versions = &drupal_static(__FUNCTION__, array()); if ($reset) { $versions = array(); diff --git a/core/modules/system/src/Tests/Update/UpdatePathTestBase.php b/core/modules/system/src/Tests/Update/UpdatePathTestBase.php index 7eb5c100fb0..702fdb2527c 100644 --- a/core/modules/system/src/Tests/Update/UpdatePathTestBase.php +++ b/core/modules/system/src/Tests/Update/UpdatePathTestBase.php @@ -192,6 +192,8 @@ abstract class UpdatePathTestBase extends WebTestBase { $this->container = \Drupal::getContainer(); $this->replaceUser1(); + + require_once \Drupal::root() . '/core/includes/update.inc'; } /** @@ -251,6 +253,28 @@ abstract class UpdatePathTestBase extends WebTestBase { if ($this->checkFailedUpdates) { $this->assertNoRaw('' . t('Failed:') . ''); + // Ensure that there are no pending updates. + foreach (['update', 'post_update'] as $update_type) { + switch ($update_type) { + case 'update': + $all_updates = update_get_update_list(); + break; + case 'post_update': + $all_updates = \Drupal::service('update.post_update_registry')->getPendingUpdateInformation(); + break; + } + foreach ($all_updates as $module => $updates) { + if (!empty($updates['pending'])) { + foreach (array_keys($updates['pending']) as $update_name) { + $this->fail("The $update_name() update function from the $module module did not run."); + } + } + } + } + // Reset the static cache of drupal_get_installed_schema_version() so that + // more complex update path testing works. + drupal_static_reset('drupal_get_installed_schema_version'); + // The config schema can be incorrect while the update functions are being // executed. But once the update has been completed, it needs to be valid // again. Assert the schema of all configuration objects now.