|
1 | | -diff -Nuar a/vendor/magento/framework/Lock/Backend/Database.php b/vendor/magento/framework/Lock/Backend/Database.php |
2 | | ---- a/vendor/magento/framework/Lock/Backend/Database.php |
3 | | -+++ b/vendor/magento/framework/Lock/Backend/Database.php |
4 | | -@@ -3,8 +3,8 @@ |
5 | | - * Copyright © Magento, Inc. All rights reserved. |
6 | | - * See COPYING.txt for license details. |
7 | | - */ |
8 | | -- |
9 | | - declare(strict_types=1); |
10 | | -+ |
11 | | - namespace Magento\Framework\Lock\Backend; |
12 | | - |
13 | | - use Magento\Framework\App\DeploymentConfig; |
14 | | -@@ -14,20 +14,44 @@ use Magento\Framework\Exception\AlreadyExistsException; |
15 | | - use Magento\Framework\Exception\InputException; |
16 | | - use Magento\Framework\Phrase; |
17 | | - |
18 | | -+/** |
19 | | -+ * Implementation of the lock manager on the basis of MySQL. |
20 | | -+ */ |
21 | | - class Database implements \Magento\Framework\Lock\LockManagerInterface |
22 | | - { |
23 | | -- /** @var ResourceConnection */ |
24 | | -+ /** |
25 | | -+ * Max time for lock is 1 week |
26 | | -+ * |
27 | | -+ * MariaDB does not support negative timeout value to get infinite timeout, |
28 | | -+ * so we set 1 week for lock timeout |
29 | | -+ */ |
30 | | -+ const MAX_LOCK_TIME = 604800; |
31 | | -+ |
32 | | -+ /** |
33 | | -+ * @var ResourceConnection |
34 | | -+ */ |
35 | | - private $resource; |
36 | | - |
37 | | -- /** @var DeploymentConfig */ |
38 | | -+ /** |
39 | | -+ * @var DeploymentConfig |
40 | | -+ */ |
41 | | - private $deploymentConfig; |
42 | | - |
43 | | -- /** @var string Lock prefix */ |
44 | | -+ /** |
45 | | -+ * @var string Lock prefix |
46 | | -+ */ |
47 | | - private $prefix; |
48 | | - |
49 | | -- /** @var string|false Holds current lock name if set, otherwise false */ |
50 | | -+ /** |
51 | | -+ * @var string|false Holds current lock name if set, otherwise false |
52 | | -+ */ |
53 | | - private $currentLock = false; |
54 | | - |
55 | | -+ /** |
56 | | -+ * @param ResourceConnection $resource |
57 | | -+ * @param DeploymentConfig $deploymentConfig |
58 | | -+ * @param string|null $prefix |
59 | | -+ */ |
60 | | - public function __construct( |
61 | | - ResourceConnection $resource, |
62 | | - DeploymentConfig $deploymentConfig, |
63 | | -@@ -46,9 +70,13 @@ class Database implements \Magento\Framework\Lock\LockManagerInterface |
64 | | - * @return bool |
65 | | - * @throws InputException |
66 | | - * @throws AlreadyExistsException |
67 | | -+ * @throws \Zend_Db_Statement_Exception |
68 | | - */ |
69 | | - public function lock(string $name, int $timeout = -1): bool |
70 | | - { |
71 | | -+ if (!$this->deploymentConfig->isDbAvailable()) { |
72 | | -+ return true; |
73 | | -+ }; |
74 | | - $name = $this->addPrefix($name); |
75 | | - |
76 | | - /** |
77 | | -@@ -59,7 +87,7 @@ class Database implements \Magento\Framework\Lock\LockManagerInterface |
78 | | - if ($this->currentLock) { |
79 | | - throw new AlreadyExistsException( |
80 | | - new Phrase( |
81 | | -- 'Current connection is already holding lock for $1, only single lock allowed', |
82 | | -+ 'Current connection is already holding lock for %1, only single lock allowed', |
83 | | - [$this->currentLock] |
84 | | - ) |
85 | | - ); |
86 | | -@@ -67,7 +95,7 @@ class Database implements \Magento\Framework\Lock\LockManagerInterface |
87 | | - |
88 | | - $result = (bool)$this->resource->getConnection()->query( |
89 | | - "SELECT GET_LOCK(?, ?);", |
90 | | -- [(string)$name, (int)$timeout] |
91 | | -+ [$name, $timeout < 0 ? self::MAX_LOCK_TIME : $timeout] |
92 | | - )->fetchColumn(); |
93 | | - |
94 | | - if ($result === true) { |
95 | | -@@ -83,9 +111,14 @@ class Database implements \Magento\Framework\Lock\LockManagerInterface |
96 | | - * @param string $name lock name |
97 | | - * @return bool |
98 | | - * @throws InputException |
99 | | -+ * @throws \Zend_Db_Statement_Exception |
100 | | - */ |
101 | | - public function unlock(string $name): bool |
102 | | - { |
103 | | -+ if (!$this->deploymentConfig->isDbAvailable()) { |
104 | | -+ return true; |
105 | | -+ }; |
106 | | -+ |
107 | | - $name = $this->addPrefix($name); |
108 | | - |
109 | | - $result = (bool)$this->resource->getConnection()->query( |
110 | | -@@ -106,14 +139,19 @@ class Database implements \Magento\Framework\Lock\LockManagerInterface |
111 | | - * @param string $name lock name |
112 | | - * @return bool |
113 | | - * @throws InputException |
114 | | -+ * @throws \Zend_Db_Statement_Exception |
115 | | - */ |
116 | | - public function isLocked(string $name): bool |
117 | | - { |
118 | | -+ if (!$this->deploymentConfig->isDbAvailable()) { |
119 | | -+ return false; |
120 | | -+ }; |
121 | | -+ |
122 | | - $name = $this->addPrefix($name); |
123 | | - |
124 | | - return (bool)$this->resource->getConnection()->query( |
125 | | - "SELECT IS_USED_LOCK(?);", |
126 | | -- [(string)$name] |
127 | | -+ [$name] |
128 | | - )->fetchColumn(); |
129 | | - } |
130 | | - |
131 | | -@@ -123,7 +161,7 @@ class Database implements \Magento\Framework\Lock\LockManagerInterface |
132 | | - * Limited to 64 characters in MySQL. |
133 | | - * |
134 | | - * @param string $name |
135 | | -- * @return string $name |
136 | | -+ * @return string |
137 | | - * @throws InputException |
138 | | - */ |
139 | | - private function addPrefix(string $name): string |
140 | 1 | diff -Nuar a/vendor/magento/module-message-queue/Console/StartConsumerCommand.php b/vendor/magento/module-message-queue/Console/StartConsumerCommand.php |
141 | 2 | --- a/vendor/magento/module-message-queue/Console/StartConsumerCommand.php |
142 | 3 | +++ b/vendor/magento/module-message-queue/Console/StartConsumerCommand.php |
|
0 commit comments