Loading core/lib/Drupal/Core/Lock/DatabaseLockBackend.php +10 −3 Original line number Diff line number Diff line Loading @@ -165,10 +165,17 @@ public function releaseAll($lock_id = NULL) { if (empty($lock_id)) { $lock_id = $this->getLockId(); } // In functional tests the test site may have been removed before the // final request has been terminated. try { $this->database->delete('semaphore') ->condition('value', $lock_id) ->execute(); } catch (\Exception $e) { $this->catchException($e); } } } /** Loading core/tests/Drupal/KernelTests/Core/Lock/LockTest.php +12 −0 Original line number Diff line number Diff line Loading @@ -4,6 +4,7 @@ namespace Drupal\KernelTests\Core\Lock; use Drupal\Core\Database\Database; use Drupal\Core\Lock\DatabaseLockBackend; use Drupal\KernelTests\KernelTestBase; Loading Loading @@ -86,6 +87,17 @@ public function testBackendLockReleaseAll(): void { $is_free = $this->lock->lockMayBeAvailable('lock_b'); $this->assertTrue($is_free, 'Second lock has been released.'); // Test that the semaphore table having been removed does not cause // exceptions. $success = $this->lock->acquire('lock_a'); $this->assertTrue($success, 'Could re-acquire first lock.'); Database::getConnection()->schema()->dropTable('semaphore'); $this->lock->releaseAll(); $is_free = $this->lock->lockMayBeAvailable('lock_a'); $this->assertTrue($is_free, 'Re-acquired lock has been released.'); } } Loading
core/lib/Drupal/Core/Lock/DatabaseLockBackend.php +10 −3 Original line number Diff line number Diff line Loading @@ -165,10 +165,17 @@ public function releaseAll($lock_id = NULL) { if (empty($lock_id)) { $lock_id = $this->getLockId(); } // In functional tests the test site may have been removed before the // final request has been terminated. try { $this->database->delete('semaphore') ->condition('value', $lock_id) ->execute(); } catch (\Exception $e) { $this->catchException($e); } } } /** Loading
core/tests/Drupal/KernelTests/Core/Lock/LockTest.php +12 −0 Original line number Diff line number Diff line Loading @@ -4,6 +4,7 @@ namespace Drupal\KernelTests\Core\Lock; use Drupal\Core\Database\Database; use Drupal\Core\Lock\DatabaseLockBackend; use Drupal\KernelTests\KernelTestBase; Loading Loading @@ -86,6 +87,17 @@ public function testBackendLockReleaseAll(): void { $is_free = $this->lock->lockMayBeAvailable('lock_b'); $this->assertTrue($is_free, 'Second lock has been released.'); // Test that the semaphore table having been removed does not cause // exceptions. $success = $this->lock->acquire('lock_a'); $this->assertTrue($success, 'Could re-acquire first lock.'); Database::getConnection()->schema()->dropTable('semaphore'); $this->lock->releaseAll(); $is_free = $this->lock->lockMayBeAvailable('lock_a'); $this->assertTrue($is_free, 'Re-acquired lock has been released.'); } }