--- 2762235-34.patch	2020-10-19 21:25:08.301665500 -0700
+++ 2762235-54.patch	2020-10-19 21:45:24.095626300 -0700
@@ -1,149 +1,115 @@
-diff --git a/core/lib/Drupal/Core/Test/TestUpdateRegistry.php b/core/lib/Drupal/Core/Test/TestUpdateRegistry.php
-new file mode 100644
-index 0000000000..34f007608c
---- /dev/null
-+++ b/core/lib/Drupal/Core/Test/TestUpdateRegistry.php
-@@ -0,0 +1,52 @@
-+<?php
-+
-+namespace Drupal\Core\Test;
-+
+diff --git a/core/modules/system/src/SystemConfigSubscriber.php b/core/modules/system/src/SystemConfigSubscriber.php
+index 0ab0d15fc6..f05a14aa22 100644
+--- a/core/modules/system/src/SystemConfigSubscriber.php
++++ b/core/modules/system/src/SystemConfigSubscriber.php
+@@ -8,6 +8,9 @@
+ use Drupal\Core\Routing\RouteBuilderInterface;
+ use Drupal\Core\StringTranslation\StringTranslationTrait;
+ use Symfony\Component\EventDispatcher\EventSubscriberInterface;
++use Drupal\Core\Extension\ModuleHandlerInterface;
 +use Drupal\Core\Update\UpdateRegistry;
-+
-+/**
-+ * TestUpdateRegistry used for tests.
-+ *
-+ * @see UpdateRegistry
-+ */
-+class TestUpdateRegistry extends UpdateRegistry {
-+
-+  /**
-+   * Constructs a new TestUpdateRegistry.
-+   */
-+  public function __construct() {}
-+
-+  /**
-+   * {@inheritdoc}
-+   */
-+  public function getPendingUpdateFunctions() {
-+    return [];
-+  }
-+
-+  /**
-+   * {@inheritdoc}
-+   */
-+  public function getPendingUpdateInformation() {
-+    return [];
-+  }
-+
-+  /**
-+   * {@inheritdoc}
-+   */
-+  public function registerInvokedUpdates(array $function_names) {
-+    return $this;
-+  }
-+
-+  /**
-+   * {@inheritdoc}
-+   */
-+  public function getModuleUpdateFunctions($module_name) {
-+    return [];
-+  }
-+
-+  /**
-+   * {@inheritdoc}
-+   */
-+  public function filterOutInvokedUpdatesByModule($module) {}
-+
-+}
-
- 
-diff --git a/core/modules/system/src/Tests/Update/UpdatePendingConfigImportTest.php b/core/modules/system/src/Tests/Update/UpdatePendingConfigImportTest.php
-new file mode 100644
-index 0000000000..3c73a07aa0
---- /dev/null
-+++ b/core/modules/system/src/Tests/Update/UpdatePendingConfigImportTest.php
-@@ -0,0 +1,78 @@
-+<?php
-+
-+namespace Drupal\system\Tests\Update;
-+
-+use Drupal\Core\Config\ConfigImporterException;
 +use Drupal\Core\Url;
-+
-+/**
-+ * Tests config imports with pending updates.
-+ *
-+ * @group Update
-+ */
-+class UpdatePendingConfigImportTest extends UpdatePathTestBase {
-+
+ 
+ /**
+  * System Config subscriber.
+@@ -22,14 +25,33 @@ class SystemConfigSubscriber implements EventSubscriberInterface {
+    */
+   protected $routerBuilder;
+ 
 +  /**
-+   * {@inheritdoc}
-+   */
-+  protected function setDatabaseDumpFiles() {
-+    $this->databaseDumpFiles = [
-+      __DIR__ . '/../../../tests/fixtures/update/drupal-8.bare.standard.php.gz',
-+      __DIR__ . '/../../../tests/fixtures/update/drupal-8.update-test-config-import.php',
-+    ];
-+  }
-+
++   * Module handler service.
++   *
++   * @var \Drupal\Core\Extension\ModuleHandlerInterface
++   */
++  protected $moduleHandler;
++
++  /**
++   * The update registry.
++   *
++   * @var \Drupal\Core\Update\UpdateRegistry
++   */
++  protected $postUpdateRegistry;
++
+   /**
+    * Constructs the SystemConfigSubscriber.
+    *
+    * @param \Drupal\Core\Routing\RouteBuilderInterface $router_builder
+    *   The router builder service.
++   * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
++   *   The module handler.
++   * @param \Drupal\Core\Update\UpdateRegistry $post_update_registry
+    */
+-  public function __construct(RouteBuilderInterface $router_builder) {
++  public function __construct(RouteBuilderInterface $router_builder, ModuleHandlerInterface $module_handler, UpdateRegistry $post_update_registry) {
+     $this->routerBuilder = $router_builder;
++    $this->moduleHandler = $module_handler;
++    $this->postUpdateRegistry = $post_update_registry;
+   }
+ 
+   /**
+@@ -80,6 +102,52 @@ public function onConfigImporterValidateSiteUUID(ConfigImporterEvent $event) {
+     }
+   }
+ 
 +  /**
-+   * {@inheritdoc}
-+   */
-+  protected function doSelectionTest() {
-+    parent::doSelectionTest();
-+    $this->assertRaw('8001 -   Pending update.');
++   * Checks for any pending database updates.
++   *
++   * As pending database update can cause issues as they potentially make
++   * changes code base and database.
++   *
++   * @see https://www.drupal.org/node/2628144
++   *
++   * @param \Drupal\Core\Config\ConfigImporterEvent $event
++   *   The config import event.
++   */
++  public function onConfigImporterValidateDatabaseUpdate(ConfigImporterEvent $event) {
++    if ($this->hasModuleUpdates()) {
++      $event->getConfigImporter()->logError(
++        $this->t('Some modules have database schema updates to install. You should run the <a href=":update">database update script</a> immediately.', [':update' => Url::fromRoute('system.db_update')->toString()])
++      );
++    }
 +  }
 +
 +  /**
-+   * Tests database update with configuration import.
-+   */
-+  public function testConfigImport() {
-+
-+    // Add 'profile' key so we don't get notices.
-+    \Drupal::configFactory()->getEditable('core.extension')->set('profile', \Drupal::installProfile())->save();
-+    // Export active config to sync.
-+    $this->copyConfig($this->container->get('config.storage'), $this->container->get('config.storage.sync'));
-+    // Get site name.
-+    $site_name = \Drupal::config('system.site')->get('name');
-+    $new_site_name = 'Overridden site name.';
-+    // Change site name.
-+    \Drupal::configFactory()->getEditable('system.site')->set('name', $new_site_name)->save();
-+
-+    try {
-+      // Try running config import with pending.
-+      $this->configImporter()->import();
-+      $error_log = [];
++   * Checks if there any pending database updates.
++   *
++   * @return bool
++   *   TRUE, if there any pending update on modules, FALSE otherwise.
++   */
++  protected function hasModuleUpdates() {
++    // Check installed modules.
++    foreach ($this->moduleHandler->getModuleList() as $module => $filename) {
++      $updates = drupal_get_schema_versions($module);
++      if ($updates !== FALSE) {
++        $default = drupal_get_installed_schema_version($module);
++        if (max($updates) > $default) {
++          return TRUE;
++        }
++      }
 +    }
-+    catch (ConfigImporterException $e) {
-+      $this->assertEqual($e->getMessage(), 'There were errors validating the config synchronization.');
-+      $error_log = $this->configImporter->getErrors();
-+    }
-+    $this->assertEqual(t('Some modules have database schema updates to install. You should run the <a href=":update">database update script</a> immediately.', [':update' => Url::fromRoute('system.db_update')->toString()]), $error_log[0]);
 +
-+    // Run database updates.
-+    $this->runUpdates();
-+    $this->drupalGet('update.php/selection');
-+    $this->assertText('No pending updates.');
-+
-+    // Check site name.
-+    $this->assertEqual($new_site_name, \Drupal::config('system.site')->get('name'));
-+
-+    // Use the UI to import (for some reason I can't get the config importer to
-+    // get rid of it's error log of pending database updates, and that error log
-+    // is probably stuck somewhere deeper).
-+    $this->drupalLogin($this->rootUser);
-+    $this->drupalGet('admin/config/development/configuration');
-+    $this->drupalPostForm(NULL, [], 'Import all');
++    // Check post update hooks.
++    $missing_post_update_functions = $this->postUpdateRegistry->getPendingUpdateFunctions();
++    if (!empty($missing_post_update_functions)) {
++      return TRUE;
++    }
 +
-+    // Site name should be reverted again.
-+    $this->assertEqual($site_name, \Drupal::config('system.site')->get('name'));
++    return FALSE;
 +  }
 +
-+}
+   /**
+    * {@inheritdoc}
+    */
+@@ -89,6 +157,7 @@ public static function getSubscribedEvents() {
+     // there is no configuration to import.
+     $events[ConfigEvents::IMPORT_VALIDATE][] = ['onConfigImporterValidateNotEmpty', 512];
+     $events[ConfigEvents::IMPORT_VALIDATE][] = ['onConfigImporterValidateSiteUUID', 256];
++    $events[ConfigEvents::IMPORT_VALIDATE][] = ['onConfigImporterValidateDatabaseUpdate', 128];
+     return $events;
+   }
+ 
 diff --git a/core/modules/system/system.services.yml b/core/modules/system/system.services.yml
-index c70889d3fd..0c4e23aa62 100644
+index b52573fc0c..dc57f3b372 100644
 --- a/core/modules/system/system.services.yml
 +++ b/core/modules/system/system.services.yml
 @@ -35,7 +35,7 @@ services:
@@ -155,79 +121,37 @@
      tags:
        - { name: event_subscriber }
    system.config_cache_tag:
-diff --git a/core/modules/system/tests/fixtures/update/drupal-8.update-test-config-import.php b/core/modules/system/tests/fixtures/update/drupal-8.update-test-config-import.php
-new file mode 100644
-index 0000000000..7993a77af8
---- /dev/null
-+++ b/core/modules/system/tests/fixtures/update/drupal-8.update-test-config-import.php
-@@ -0,0 +1,40 @@
-+<?php
-+
-+/**
-+ * @file
-+ * Partial database to mimic the installation of the update_test_post_update
-+ * module.
-+ */
-+
-+use Drupal\Core\Database\Database;
-+
-+$connection = Database::getConnection();
-+
-+// Set the schema version.
-+$connection->merge('key_value')
-+  ->condition('collection', 'system.schema')
-+  ->condition('name', 'update_test_config_import')
-+  ->fields([
-+    'collection' => 'system.schema',
-+    'name' => 'update_test_config_import',
-+    'value' => 'i:8000;',
-+  ])
-+  ->execute();
-+
-+// Update core.extension.
-+$extensions = $connection->select('config')
-+  ->fields('config', ['data'])
-+  ->condition('collection', '')
-+  ->condition('name', 'core.extension')
-+  ->execute()
-+  ->fetchField();
-+$extensions = unserialize($extensions);
-+$extensions['module']['update_test_config_import'] = 8000;
-+$extensions['theme']['stable'] = 0;
-+$connection->update('config')
-+  ->fields([
-+    'data' => serialize($extensions),
-+  ])
-+  ->condition('collection', '')
-+  ->condition('name', 'core.extension')
-+  ->execute();
-diff --git a/core/modules/system/tests/modules/update_test_config_import/update_test_config_import.info.yml b/core/modules/system/tests/modules/update_test_config_import/update_test_config_import.info.yml
-new file mode 100644
-index 0000000000..faf112fb3e
---- /dev/null
-+++ b/core/modules/system/tests/modules/update_test_config_import/update_test_config_import.info.yml
-@@ -0,0 +1,5 @@
-+core: 8.x
-+name: Update test config import
-+type: module
-+package: Testing
-+version: VERSION
-diff --git a/core/modules/system/tests/modules/update_test_config_import/update_test_config_import.install b/core/modules/system/tests/modules/update_test_config_import/update_test_config_import.install
-new file mode 100644
-index 0000000000..11ec5e3d0e
---- /dev/null
-+++ b/core/modules/system/tests/modules/update_test_config_import/update_test_config_import.install
-@@ -0,0 +1,12 @@
-+<?php
-+
-+/**
-+ * @file
-+ * Install hooks for test module.
-+ */
-+
-+/**
-+ * Pending update.
-+ */
-+function update_test_config_import_update_8001() {
-+}
-
+diff --git a/core/tests/Drupal/KernelTests/KernelTestBase.php b/core/tests/Drupal/KernelTests/KernelTestBase.php
+index d3ae0992d4..67feb33ca8 100644
+--- a/core/tests/Drupal/KernelTests/KernelTestBase.php
++++ b/core/tests/Drupal/KernelTests/KernelTestBase.php
+@@ -30,6 +30,7 @@
+ use org\bovigo\vfs\visitor\vfsStreamPrintVisitor;
+ use Symfony\Cmf\Component\Routing\RouteObjectInterface;
+ use Symfony\Component\Routing\Route;
++use Drupal\Core\Test\TestUpdateRegistry;
+ 
+ /**
+  * Base class for functional integration tests.
+@@ -552,6 +553,10 @@ public function register(ContainerBuilder $container) {
+         ->addTag('event_subscriber');
+     }
+ 
++    // We don't care about post updates in the kernel test base.
++    $container->removeDefinition('update.post_update_registry');
++    $container->register('update.post_update_registry', TestUpdateRegistry::class);
++
+     if ($container->hasDefinition('path_alias.path_processor')) {
+       // The alias-based processor requires the path_alias entity schema to be
+       // installed, so we prevent it from being registered to the path processor
+@@ -727,6 +732,10 @@ protected function installSchema($module, $tables) {
+         throw new \LogicException("$module module does not define a schema for table '$table'.");
+       }
+       $this->container->get('database')->schema()->createTable($table, $schema);
++
++      // Set a very high schema version so no updates are found because we
++      // don't want to run them anyway.
++      drupal_set_installed_schema_version($module, PHP_INT_MAX);
+     }
+   }
+ 
