diff --git a/core/core.services.yml b/core/core.services.yml index f30cee7..b565b13 100644 --- a/core/core.services.yml +++ b/core/core.services.yml @@ -338,6 +338,9 @@ services: lock: class: Drupal\Core\Lock\DatabaseLockBackend arguments: ['@database'] + 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 dbf340f..710077f 100644 --- a/core/lib/Drupal/Core/Config/ConfigImporter.php +++ b/core/lib/Drupal/Core/Config/ConfigImporter.php @@ -1027,7 +1027,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 7c48dd5..f8e7ea5 100644 --- a/core/modules/config/src/Form/ConfigSync.php +++ b/core/modules/config/src/Form/ConfigSync.php @@ -132,7 +132,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 7e8024a..892a575 100644 --- a/core/modules/config/src/Tests/ConfigImportRenameValidationTest.php +++ b/core/modules/config/src/Tests/ConfigImportRenameValidationTest.php @@ -64,7 +64,7 @@ public 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 6f3bb2c..e470f39 100644 --- a/core/modules/config/src/Tests/ConfigImportUITest.php +++ b/core/modules/config/src/Tests/ConfigImportUITest.php @@ -233,14 +233,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 ca4d704..e5619eb 100644 --- a/core/modules/config/src/Tests/ConfigImporterTest.php +++ b/core/modules/config/src/Tests/ConfigImporterTest.php @@ -533,4 +533,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 65489f8..2059c97 100644 --- a/core/modules/simpletest/src/KernelTestBase.php +++ b/core/modules/simpletest/src/KernelTestBase.php @@ -252,6 +252,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