mirror of
https://github.com/yiisoft/yii2.git
synced 2025-08-26 06:15:19 +08:00
Co-authored-by: Márton Somogyi <somogyi.marton@metrisoft.hu>
This commit is contained in:
@ -16,6 +16,7 @@ Yii Framework 2 Change Log
|
||||
- Bug #19589: Fix Error reporting in to the `BaseArrayHelper::getValue()` (lav45)
|
||||
- Bug #19316: Fix MysqlMutex with same connection but difference database (kamarton)
|
||||
- Bug #19507: Fix eager loading of nested one-to-many relations (spo0okie)
|
||||
- Bug #19316: Fix MysqlMutex long name (kamarton)
|
||||
|
||||
|
||||
2.0.46 August 18, 2022
|
||||
|
@ -69,7 +69,7 @@ class MysqlMutex extends DbMutex
|
||||
return $this->db->useMaster(function ($db) use ($name, $timeout) {
|
||||
/** @var \yii\db\Connection $db */
|
||||
return (bool) $db->createCommand(
|
||||
'SELECT GET_LOCK(CONCAT(:prefix, :name), :timeout)',
|
||||
'SELECT GET_LOCK(SUBSTRING(CONCAT(:prefix, :name), 1, 64), :timeout)',
|
||||
[':name' => $this->hashLockName($name), ':timeout' => $timeout, ':prefix' => $this->keyPrefix]
|
||||
)->queryScalar();
|
||||
});
|
||||
@ -86,7 +86,7 @@ class MysqlMutex extends DbMutex
|
||||
return $this->db->useMaster(function ($db) use ($name) {
|
||||
/** @var \yii\db\Connection $db */
|
||||
return (bool) $db->createCommand(
|
||||
'SELECT RELEASE_LOCK(CONCAT(:prefix, :name))',
|
||||
'SELECT RELEASE_LOCK(SUBSTRING(CONCAT(:prefix, :name), 1, 64))',
|
||||
[':name' => $this->hashLockName($name), ':prefix' => $this->keyPrefix]
|
||||
)->queryScalar();
|
||||
});
|
||||
|
@ -53,6 +53,22 @@ class MysqlMutexTest extends DatabaseTestCase
|
||||
$this->assertTrue($mutexTwo->release($mutexName));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider mutexDataProvider()
|
||||
*
|
||||
* @param string $mutexName
|
||||
*/
|
||||
public function testThatMutexLocksWithKeyPrefixesLongString($mutexName)
|
||||
{
|
||||
$mutexOne = $this->createMutex(['keyPrefix' => str_repeat('a', 40)]);
|
||||
$mutexTwo = $this->createMutex(['keyPrefix' => str_repeat('b', 40)]);
|
||||
|
||||
$this->assertTrue($mutexOne->acquire($mutexName));
|
||||
$this->assertTrue($mutexTwo->acquire($mutexName));
|
||||
$this->assertTrue($mutexOne->release($mutexName));
|
||||
$this->assertTrue($mutexTwo->release($mutexName));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider mutexDataProvider()
|
||||
*
|
||||
|
Reference in New Issue
Block a user