diff --git a/core/includes/common.inc b/core/includes/common.inc index a4805c0..662705d 100644 --- a/core/includes/common.inc +++ b/core/includes/common.inc @@ -3262,7 +3262,7 @@ function drupal_cron_run() { watchdog('cron', 'Cron run completed.', array(), WATCHDOG_NOTICE); // Release cron lock. - lock()->release('cron'); + Drupal::lock()->release('cron'); // Return TRUE so other functions can check if it did run successfully $return = TRUE; diff --git a/core/includes/menu.inc b/core/includes/menu.inc index c90575e..8f6423a 100644 --- a/core/includes/menu.inc +++ b/core/includes/menu.inc @@ -2715,11 +2715,11 @@ function menu_reset_static_cache() { * in parallel and the current thread just waited for completion. */ function menu_router_rebuild() { - if (!lock()->acquire(__FUNCTION__)) { + if (!Drupal::lock()->acquire(__FUNCTION__)) { // Wait for another request that is already doing this work. // We choose to block here since otherwise the router item may not // be available during routing resulting in a 404. - lock()->wait(__FUNCTION__); + Drupal::lock()->wait(__FUNCTION__); return FALSE; } @@ -2739,7 +2739,7 @@ function menu_router_rebuild() { watchdog_exception('menu', $e); } - lock()->release(__FUNCTION__); + Drupal::lock()->release(__FUNCTION__); return TRUE; } diff --git a/core/lib/Drupal/Core/Utility/CacheArray.php b/core/lib/Drupal/Core/Utility/CacheArray.php index 9748753..d2d91a0 100644 --- a/core/lib/Drupal/Core/Utility/CacheArray.php +++ b/core/lib/Drupal/Core/Utility/CacheArray.php @@ -202,13 +202,13 @@ protected function set($data, $lock = TRUE) { // Lock cache writes to help avoid stampedes. // To implement locking for cache misses, override __construct(). $lock_name = $this->cid . ':' . $this->bin; - if (!$lock || lock()->acquire($lock_name)) { + if (!$lock || Drupal::lock()->acquire($lock_name)) { if ($cached = cache($this->bin)->get($this->cid)) { $data = $cached->data + $data; } cache($this->bin)->set($this->cid, $data, CacheBackendInterface::CACHE_PERMANENT, $this->tags); if ($lock) { - lock()->release($lock_name); + Drupal::lock()->release($lock_name); } } } diff --git a/core/lib/Drupal/Core/Utility/ThemeRegistry.php b/core/lib/Drupal/Core/Utility/ThemeRegistry.php index eb2dd80..eaa1379 100644 --- a/core/lib/Drupal/Core/Utility/ThemeRegistry.php +++ b/core/lib/Drupal/Core/Utility/ThemeRegistry.php @@ -126,7 +126,7 @@ public function resolveCacheMiss($offset) { */ public function set($data, $lock = TRUE) { $lock_name = $this->cid . ':' . $this->bin; - if (!$lock || lock()->acquire($lock_name)) { + if (!$lock || Drupal::lock()->acquire($lock_name)) { if ($cached = cache($this->bin)->get($this->cid)) { // Use array merge instead of union so that filled in values in $data // overwrite empty values in the current cache. @@ -138,7 +138,7 @@ public function set($data, $lock = TRUE) { } cache($this->bin)->set($this->cid, $data, CacheBackendInterface::CACHE_PERMANENT, $this->tags); if ($lock) { - lock()->release($lock_name); + Drupal::lock()->release($lock_name); } } } diff --git a/core/modules/comment/lib/Drupal/comment/Plugin/Core/Entity/Comment.php b/core/modules/comment/lib/Drupal/comment/Plugin/Core/Entity/Comment.php index 27dbf17..9abc19c 100644 --- a/core/modules/comment/lib/Drupal/comment/Plugin/Core/Entity/Comment.php +++ b/core/modules/comment/lib/Drupal/comment/Plugin/Core/Entity/Comment.php @@ -327,7 +327,7 @@ public function postSave(EntityStorageControllerInterface $storage_controller, $ */ protected function releaseThreadLock() { if ($this->threadLock) { - lock()->release($this->threadLock); + Drupal::lock()->release($this->threadLock); $this->threadLock = ''; } } 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 bf868db..5aaa8d7 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Lock/LockFunctionalTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Lock/LockFunctionalTest.php @@ -37,7 +37,7 @@ public function testLockAcquire() { $lock_not_acquired = 'FALSE: Lock not acquired in 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'); + Drupal::lock()->release('system_test_lock_acquire'); // Cause another request to acquire the lock. $this->drupalGet('system-test/lock-acquire'); @@ -47,7 +47,7 @@ public function testLockAcquire() { // 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'); - lock()->release('system_test_lock_acquire'); + Drupal::lock()->release('system_test_lock_acquire'); // Try a very short timeout and lock breaking. $this->assertTrue(lock()->acquire('system_test_lock_acquire', 0.5), 'Lock acquired by this request.', 'Lock'); diff --git a/core/modules/system/tests/modules/system_test/system_test.module b/core/modules/system/tests/modules/system_test/system_test.module index ea10a04..a44288e 100644 --- a/core/modules/system/tests/modules/system_test/system_test.module +++ b/core/modules/system/tests/modules/system_test/system_test.module @@ -170,8 +170,8 @@ function system_test_system_info_alter(&$info, $file, $type) { * Try to acquire a named lock and report the outcome. */ function system_test_lock_acquire() { - if (lock()->acquire('system_test_lock_acquire')) { - lock()->release('system_test_lock_acquire'); + if (Drupal::lock()->acquire('system_test_lock_acquire')) { + Drupal::lock()->release('system_test_lock_acquire'); return 'TRUE: Lock successfully acquired in system_test_lock_acquire()'; } else {