diff --git a/core/includes/bootstrap.inc b/core/includes/bootstrap.inc index 1eb63b6..5dab5cb 100644 --- a/core/includes/bootstrap.inc +++ b/core/includes/bootstrap.inc @@ -2493,6 +2493,8 @@ function drupal_container(Container $new_container = NULL, $rebuild = FALSE) { // Register the EntityManager. $container->register('plugin.manager.entity', 'Drupal\Core\Entity\EntityManager'); + // Register the lock backend. + $container->register('lock', 'Drupal\Core\Lock\DatabaseLockBackend'); } return $container; } @@ -3548,27 +3550,7 @@ function drupal_php_storage($name = 'default') { * @return Drupal\Core\Lock\LockBackendInterface */ function lock() { - $lock_backend = &drupal_static(__FUNCTION__); - - if (!isset($lock_backend)) { - $class_name = variable_get('lock_backend', 'Drupal\Core\Lock\DatabaseLockBackend'); - - // Do not allow a WSOD here, if the class does not exists use the default - // one. - // @todo We should log failed class loading for debugging, but for that we - // need an early watchdog function that logs into a file if the database - // is not present. - if (class_exists($class_name)) { - $lock_backend = new $class_name(); - } - else { - $lock_backend = new DatabaseLockBackend(); - } - - drupal_register_shutdown_function(array($lock_backend, 'releaseAll')); - } - - return $lock_backend; + return drupal_container()->get('lock'); } /** diff --git a/core/includes/install.core.inc b/core/includes/install.core.inc index d5983b6..4d2926e 100644 --- a/core/includes/install.core.inc +++ b/core/includes/install.core.inc @@ -322,6 +322,14 @@ function install_begin_request(&$install_state) { $container->register('config.factory', 'Drupal\Core\Config\ConfigFactory') ->addArgument(new Reference('config.storage')) ->addArgument(new Reference('dispatcher')); + // The install process cannot use the database lock backend since the database + // is not fully up, so we use a null backend implementation during the + // installation process. This will also speed up the installation process. + // The site being installed will use the real lock backend when doing AJAX + // requests but, except for a WSOD, there is no chance for a a lock to stall + // (as opposed to the cache backend) so we can afford having a null + // implementation here. + $container->register('lock', 'Drupal\Core\Lock\NullLockBackend'); drupal_container($container); } @@ -346,15 +354,6 @@ function install_begin_request(&$install_state) { require_once DRUPAL_ROOT . '/core/includes/cache.inc'; $conf['cache_classes'] = array('cache' => 'Drupal\Core\Cache\InstallBackend'); - // The install process cannot use the database lock backend since the database - // is not fully up, so we use a null backend implementation during the - // installation process. This will also speed up the installation process. - // The site being installed will use the real lock backend when doing AJAX - // requests but, except for a WSOD, there is no chance for a a lock to stall - // (as opposed to the cache backend) so we can afford having a null - // implementation here. - $conf['lock_backend'] = 'Drupal\Core\Lock\NullLockBackend'; - // Prepare for themed output. We need to run this at the beginning of the // page request to avoid a different theme accidentally getting set. (We also // need to run it even in the case of command-line installations, to prevent diff --git a/core/lib/Drupal/Core/CoreBundle.php b/core/lib/Drupal/Core/CoreBundle.php index bbc4e2e..13db480 100644 --- a/core/lib/Drupal/Core/CoreBundle.php +++ b/core/lib/Drupal/Core/CoreBundle.php @@ -56,7 +56,6 @@ public function build(ContainerBuilder $container) { ->addArgument('slave'); $container->register('typed_data', 'Drupal\Core\TypedData\TypedDataManager'); // Add the user's storage for temporary, non-cache data. - $container->register('lock', 'Drupal\Core\Lock\DatabaseLockBackend'); $container->register('user.tempstore', 'Drupal\user\TempStoreFactory') ->addArgument(new Reference('database')) ->addArgument(new Reference('lock')); diff --git a/core/lib/Drupal/Core/Lock/DatabaseLockBackend.php b/core/lib/Drupal/Core/Lock/DatabaseLockBackend.php index d877dba..db0aaa0 100644 --- a/core/lib/Drupal/Core/Lock/DatabaseLockBackend.php +++ b/core/lib/Drupal/Core/Lock/DatabaseLockBackend.php @@ -114,4 +114,11 @@ public function releaseAll($lock_id = NULL) { ->condition('value', $lock_id) ->execute(); } + + /** + * Releases pending locks. + */ + public function __destruct() { + //$this->releaseAll(); + } } diff --git a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php index 694a763..cec0630 100644 --- a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php +++ b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php @@ -723,9 +723,8 @@ protected function setUp() { $batch = &batch_get(); $batch = $this->originalBatch; - // Revert install_begin_request() cache and lock service overrides. + // Revert install_begin_request() cache service overrides. unset($conf['cache_classes']); - unset($conf['lock_backend']); // Set path variables. variable_set('file_public_path', $this->public_files_directory);