diff --git a/core/core.services.yml b/core/core.services.yml index dec001f..5256787 100644 --- a/core/core.services.yml +++ b/core/core.services.yml @@ -392,6 +392,9 @@ services: arguments: ['@database'] tags: - { name: backend_overridable } + lock.persistent: + class: Drupal\Core\Lock\PersistentDatabaseLockBackend + arguments: ['@database'] router.request_context: class: Symfony\Component\Routing\RequestContext tags: diff --git a/core/lib/Drupal/Core/Config/ConfigImporter.php b/core/lib/Drupal/Core/Config/ConfigImporter.php index e060cdf..c1bced3 100644 --- a/core/lib/Drupal/Core/Config/ConfigImporter.php +++ b/core/lib/Drupal/Core/Config/ConfigImporter.php @@ -1042,7 +1042,7 @@ public function alreadyImporting() { protected function reInjectMe() { $this->eventDispatcher = \Drupal::service('event_dispatcher'); $this->configManager = \Drupal::service('config.manager'); - $this->lock = \Drupal::lock(); + $this->lock = \Drupal::service('lock.persistent'); $this->typedConfigManager = \Drupal::service('config.typed'); $this->moduleHandler = \Drupal::moduleHandler(); $this->themeHandler = \Drupal::service('theme_handler'); diff --git a/core/lib/Drupal/Core/Lock/PersistentDatabaseLockBackend.php b/core/lib/Drupal/Core/Lock/PersistentDatabaseLockBackend.php new file mode 100644 index 0000000..6aae072 --- /dev/null +++ b/core/lib/Drupal/Core/Lock/PersistentDatabaseLockBackend.php @@ -0,0 +1,34 @@ +database = $database; + // Also set the lockId to a static global value to make the lock Drupal + // global. + $this->lockId = 'persistent'; + } +} diff --git a/core/modules/config/src/Form/ConfigSync.php b/core/modules/config/src/Form/ConfigSync.php index 70c0c73..17e5782 100644 --- a/core/modules/config/src/Form/ConfigSync.php +++ b/core/modules/config/src/Form/ConfigSync.php @@ -133,7 +133,7 @@ public static function create(ContainerInterface $container) { return new static( $container->get('config.storage.staging'), $container->get('config.storage'), - $container->get('lock'), + $container->get('lock.persistent'), $container->get('event_dispatcher'), $container->get('config.manager'), $container->get('url_generator'), diff --git a/core/modules/config/src/Tests/ConfigImportRenameValidationTest.php b/core/modules/config/src/Tests/ConfigImportRenameValidationTest.php index 60aab7f..fc0d0ed 100644 --- a/core/modules/config/src/Tests/ConfigImportRenameValidationTest.php +++ b/core/modules/config/src/Tests/ConfigImportRenameValidationTest.php @@ -55,7 +55,7 @@ protected function setUp() { $storage_comparer->createChangelist(), $this->container->get('event_dispatcher'), $this->container->get('config.manager'), - $this->container->get('lock'), + $this->container->get('lock.persistent'), $this->container->get('config.typed'), $this->container->get('module_handler'), $this->container->get('theme_handler'), diff --git a/core/modules/config/src/Tests/ConfigImportUITest.php b/core/modules/config/src/Tests/ConfigImportUITest.php index cbb2a61..80aac10 100644 --- a/core/modules/config/src/Tests/ConfigImportUITest.php +++ b/core/modules/config/src/Tests/ConfigImportUITest.php @@ -227,14 +227,14 @@ function testImportLock() { // Acquire a fake-lock on the import mechanism. $config_importer = $this->configImporter(); - $this->container->get('lock')->acquire($config_importer::LOCK_ID); + $this->container->get('lock.persistent')->acquire($config_importer::LOCK_ID); // Attempt to import configuration and verify that an error message appears. $this->drupalPostForm(NULL, array(), t('Import all')); $this->assertText(t('Another request may be synchronizing configuration already.')); // Release the lock, just to keep testing sane. - $this->container->get('lock')->release($config_importer::LOCK_ID); + $this->container->get('lock.persistent')->release($config_importer::LOCK_ID); // Verify site name has not changed. $this->assertNotEqual($new_site_name, \Drupal::config('system.site')->get('name')); diff --git a/core/modules/config/src/Tests/ConfigImporterTest.php b/core/modules/config/src/Tests/ConfigImporterTest.php index e5e760e..b98a772 100644 --- a/core/modules/config/src/Tests/ConfigImporterTest.php +++ b/core/modules/config/src/Tests/ConfigImporterTest.php @@ -527,4 +527,3 @@ function testUpdated() { $this->assertEqual(count($logs), 0); } } - diff --git a/core/modules/simpletest/src/KernelTestBase.php b/core/modules/simpletest/src/KernelTestBase.php index afea590..1a16229 100644 --- a/core/modules/simpletest/src/KernelTestBase.php +++ b/core/modules/simpletest/src/KernelTestBase.php @@ -253,6 +253,7 @@ public function containerBuild(ContainerBuilder $container) { $this->container->setParameter('language.default_values', Language::$defaultValues); $container->register('lock', 'Drupal\Core\Lock\NullLockBackend'); + $container->register('lock.persistent', 'Drupal\Core\Lock\NullLockBackend'); $container->register('cache_factory', 'Drupal\Core\Cache\MemoryBackendFactory'); $container