diff --git a/framework/CHANGELOG.md b/framework/CHANGELOG.md index d0482ac773..55e91284a9 100644 --- a/framework/CHANGELOG.md +++ b/framework/CHANGELOG.md @@ -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 ----------------------- diff --git a/framework/mutex/FileMutex.php b/framework/mutex/FileMutex.php index 7f402f19d2..d06a1f5076 100644 --- a/framework/mutex/FileMutex.php +++ b/framework/mutex/FileMutex.php @@ -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);