mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-02 21:41:19 +08:00
Fixes #16838: yii\mutex\Mutex::acquire() no longer returns true if lock is already acquired by the same component in the same process
This commit is contained in:
committed by
Alexander Makarov
parent
5208ef761e
commit
1fe3d61a3b
@ -78,6 +78,7 @@ Yii Framework 2 Change Log
|
||||
- Bug #15204: `yii\helpers\BaseInflector::slug()` is not removing substrings matching provided replacement from given string anymore (bizley)
|
||||
- Bug #16101: Fixed Error Handler to clear registered meta tags, link tags, css/js scripts and files in error view (bizley)
|
||||
- Bug #16836: Fix `yii\mutex\MysqlMutex` to handle locks with names longer than 64 characters (rob006)
|
||||
- Bug #16838: `yii\mutex\Mutex::acquire()` no longer returns `true` if lock is already acquired by the same component in the same process (rob006)
|
||||
- Enh #16839: Increase frequency of lock tries for `yii\mutex\FileMutex::acquireLock()` when $timeout is provided (rob006)
|
||||
- Enh #16839: Add support for `$timeout` in `yii\mutex\PgsqlMutex::acquire()` (rob006)
|
||||
- Bug #16828: `yii\console\controllers\MessageController::translator` recognized object' methods and functions calls as identical sets of tokens (erickskrauch)
|
||||
|
||||
@ -62,6 +62,17 @@ Upgrade from Yii 2.0.15
|
||||
```json
|
||||
"cebe/markdown": "~1.1.0",
|
||||
```
|
||||
|
||||
* `yii\mutex\Mutex::acquire()` no longer returns `true` if lock is already acquired by the same component in the same process.
|
||||
Make sure that you're not trying to acquire the same lock multiple times in a way that may create infinite loops, for example:
|
||||
|
||||
```php
|
||||
if (Yii::$app->mutex->acquire('test')) {
|
||||
while (!Yii::$app->mutex->acquire('test')) {
|
||||
// `Yii::$app->mutex->acquire('test')` will always return `false` here, since lock is already acquired
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
Upgrade from Yii 2.0.14
|
||||
|
||||
@ -69,7 +69,7 @@ abstract class Mutex extends Component
|
||||
*/
|
||||
public function acquire($name, $timeout = 0)
|
||||
{
|
||||
if ($this->acquireLock($name, $timeout)) {
|
||||
if (!in_array($name, $this->_locks, true) && $this->acquireLock($name, $timeout)) {
|
||||
$this->_locks[] = $name;
|
||||
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user