Patched to Drupal 8.4.8 level. See https://www.drupal.org/sa-core-2018-004 and patch...
[yaffs-website] / web / core / lib / Drupal / Core / Lock / NullLockBackend.php
1 <?php
2
3 namespace Drupal\Core\Lock;
4
5 /**
6  * Defines a Null lock backend.
7  *
8  * This implementation won't actually lock anything and will always succeed on
9  * lock attempts.
10  *
11  * @ingroup lock
12  */
13 class NullLockBackend implements LockBackendInterface {
14
15   /**
16    * Current page lock token identifier.
17    *
18    * @var string
19    */
20   protected $lockId;
21
22   /**
23    * {@inheritdoc}
24    */
25   public function acquire($name, $timeout = 30.0) {
26     return TRUE;
27   }
28
29   /**
30    * {@inheritdoc}
31    */
32   public function lockMayBeAvailable($name) {
33     return TRUE;
34   }
35
36   /**
37    * {@inheritdoc}
38    */
39   public function wait($name, $delay = 30) {}
40
41   /**
42    * {@inheritdoc}
43    */
44   public function release($name) {}
45
46   /**
47    * {@inheritdoc}
48    */
49   public function releaseAll($lock_id = NULL) {}
50
51   /**
52    * {@inheritdoc}
53    */
54   public function getLockId() {
55     if (!isset($this->lockId)) {
56       $this->lockId = uniqid(mt_rand(), TRUE);
57     }
58     return $this->lockId;
59   }
60
61 }