diff --git a/core/lib/Drupal/Core/Lock/LockBackendInterface.php b/core/lib/Drupal/Core/Lock/LockBackendInterface.php index 778e616..ca2a4d8 100644 --- a/core/lib/Drupal/Core/Lock/LockBackendInterface.php +++ b/core/lib/Drupal/Core/Lock/LockBackendInterface.php @@ -59,10 +59,14 @@ * \Drupal::lock()->acquire() and \Drupal::lock()->wait() will automatically * break (delete) a lock whose duration has exceeded the timeout specified when * it was acquired. + * + * @} End of "defgroup lock". */ /** * Lock backend interface. + * + * @ingroup lock */ interface LockBackendInterface { @@ -131,7 +135,3 @@ public function releaseAll($lockId = NULL); */ public function getLockId(); } - -/** - * @} End of "defgroup lock". - */ diff --git a/core/modules/system/lib/Drupal/system/Tests/Lock/LockFunctionalTest.php b/core/modules/system/lib/Drupal/system/Tests/Lock/LockFunctionalTest.php index d72c667..d105c10 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Lock/LockFunctionalTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Lock/LockFunctionalTest.php @@ -33,36 +33,37 @@ public static function getInfo() { * Confirms that we can acquire and release locks in two parallel requests. */ public function testLockAcquire() { + $lock = $this->container->get('lock'); $lock_acquired = 'TRUE: Lock successfully acquired in system_test_lock_acquire()'; $lock_not_acquired = 'FALSE: Lock not acquired in system_test_lock_acquire()'; - $this->assertTrue(\Drupal::lock()->acquire('system_test_lock_acquire'), 'Lock acquired by this request.', 'Lock'); - $this->assertTrue(\Drupal::lock()->acquire('system_test_lock_acquire'), 'Lock extended by this request.', 'Lock'); - \Drupal::lock()->release('system_test_lock_acquire'); + $this->assertTrue($lock->acquire('system_test_lock_acquire'), 'Lock acquired by this request.', 'Lock'); + $this->assertTrue($lock->acquire('system_test_lock_acquire'), 'Lock extended by this request.', 'Lock'); + $lock->release('system_test_lock_acquire'); // Cause another request to acquire the lock. $this->drupalGet('system-test/lock-acquire'); $this->assertText($lock_acquired, 'Lock acquired by the other request.', 'Lock'); // The other request has finished, thus it should have released its lock. - $this->assertTrue(\Drupal::lock()->acquire('system_test_lock_acquire'), 'Lock acquired by this request.', 'Lock'); + $this->assertTrue($lock->acquire('system_test_lock_acquire'), 'Lock acquired by this request.', 'Lock'); // This request holds the lock, so the other request cannot acquire it. $this->drupalGet('system-test/lock-acquire'); $this->assertText($lock_not_acquired, 'Lock not acquired by the other request.', 'Lock'); - \Drupal::lock()->release('system_test_lock_acquire'); + $lock->release('system_test_lock_acquire'); // Try a very short timeout and lock breaking. - $this->assertTrue(\Drupal::lock()->acquire('system_test_lock_acquire', 0.5), 'Lock acquired by this request.', 'Lock'); + $this->assertTrue($lock->acquire('system_test_lock_acquire', 0.5), 'Lock acquired by this request.', 'Lock'); sleep(1); // The other request should break our lock. $this->drupalGet('system-test/lock-acquire'); $this->assertText($lock_acquired, 'Lock acquired by the other request, breaking our lock.', 'Lock'); // We cannot renew it, since the other thread took it. - $this->assertFalse(\Drupal::lock()->acquire('system_test_lock_acquire'), 'Lock cannot be extended by this request.', 'Lock'); + $this->assertFalse($lock->acquire('system_test_lock_acquire'), 'Lock cannot be extended by this request.', 'Lock'); // Check the shut-down function. $lock_acquired_exit = 'TRUE: Lock successfully acquired in system_test_lock_exit()'; $lock_not_acquired_exit = 'FALSE: Lock not acquired in system_test_lock_exit()'; $this->drupalGet('system-test/lock-exit'); $this->assertText($lock_acquired_exit, 'Lock acquired by the other request before exit.', 'Lock'); - $this->assertTrue(\Drupal::lock()->acquire('system_test_lock_exit'), 'Lock acquired by this request after the other request exits.', 'Lock'); + $this->assertTrue($lock->acquire('system_test_lock_exit'), 'Lock acquired by this request after the other request exits.', 'Lock'); } }