mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-02 13:02:24 +08:00
Fixes #16603: Added yii\mutex\FileMutex::$isWindows for Windows file shares on Unix guest machines
This commit is contained in:
committed by
Alexander Makarov
parent
b197d8535c
commit
0ddc3bf58c
@ -44,6 +44,7 @@ Yii Framework 2 Change Log
|
||||
- Bug #15889: Fixed override `yii\helpers\Html::setActivePlaceholder` (lesha724)
|
||||
- Bug #16552: Added check in `yii\db\ActiveQuery::prepare()` to prevent populating already populated relation when another relation is requested with `via` (drlibra)
|
||||
- Enh #16522: Allow jQuery 3.3 (Slamdunk)
|
||||
- Enh #16603: Added `yii\mutex\FileMutex::$isWindows` for Windows file shares on Unix guest machines (brandonkelly)
|
||||
|
||||
2.0.15.1 March 21, 2018
|
||||
-----------------------
|
||||
|
||||
@ -59,6 +59,13 @@ class FileMutex extends Mutex
|
||||
* but read-only for other users.
|
||||
*/
|
||||
public $dirMode = 0775;
|
||||
/**
|
||||
* @var bool whether file handling should assume a Windows file system.
|
||||
* This value will determine how [[releaseLock()]] goes about deleting the lock file.
|
||||
* If not set, it will be determined by checking the DIRECTORY_SEPARATOR constant.
|
||||
* @since 2.0.16
|
||||
*/
|
||||
public $isWindows;
|
||||
|
||||
/**
|
||||
* @var resource[] stores all opened lock files. Keys are lock names and values are file handles.
|
||||
@ -78,6 +85,9 @@ class FileMutex extends Mutex
|
||||
if (!is_dir($this->mutexPath)) {
|
||||
FileHelper::createDirectory($this->mutexPath, $this->dirMode, true);
|
||||
}
|
||||
if ($this->isWindows === null) {
|
||||
$this->isWindows = DIRECTORY_SEPARATOR === '\\';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -149,7 +159,7 @@ class FileMutex extends Mutex
|
||||
return false;
|
||||
}
|
||||
|
||||
if (DIRECTORY_SEPARATOR === '\\') {
|
||||
if ($this->isWindows) {
|
||||
// Under windows it's not possible to delete a file opened via fopen (either by own or other process).
|
||||
// That's why we must first unlock and close the handle and then *try* to delete the lock file.
|
||||
flock($this->_files[$name], LOCK_UN);
|
||||
|
||||
Reference in New Issue
Block a user