diff options
author | Matthieu Aubry <mattab@users.noreply.github.com> | 2020-01-16 07:46:53 +0300 |
---|---|---|
committer | diosmosis <diosmosis@users.noreply.github.com> | 2020-01-16 07:46:53 +0300 |
commit | f284ec7ba88cc0c2ad8ea043e7f04759319da8f6 (patch) | |
tree | 19b278a53e124301a792a461a2552ce6d7dea592 /core/Concurrency | |
parent | e179798498f92f3462f21d9188516354c8ccc34b (diff) |
Fix Could not get the lock for ID, when creating a site (#15401)
* Lock key start
* do not empty key lock
Co-authored-by: Thomas Steur <tsteur@users.noreply.github.com>
Diffstat (limited to 'core/Concurrency')
-rw-r--r-- | core/Concurrency/Lock.php | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/core/Concurrency/Lock.php b/core/Concurrency/Lock.php index f63bec640a..e16b3465ce 100644 --- a/core/Concurrency/Lock.php +++ b/core/Concurrency/Lock.php @@ -50,11 +50,15 @@ class Lock public function execute($id, $callback) { - if (Common::mb_strlen($id) > self::MAX_KEY_LEN) { + $maxLen = self::MAX_KEY_LEN; + if (!empty($this->lockKeyStart)) { + $maxLen = $maxLen - strlen($this->lockKeyStart); + } + if (Common::mb_strlen($id) > $maxLen) { // Lock key might be too long for DB column, so we hash it but leave the start of the original as well // to make it more readable $md5Len = 32; - $id = Common::mb_substr($id, 0, self::MAX_KEY_LEN - $md5Len - 1) . md5($id); + $id = Common::mb_substr($id, 0, $maxLen - $md5Len - 1) . md5($id); } $i = 0; |