diff --git a/CHANGELOG-v3.md b/CHANGELOG-v3.md index aad8919d570..d2c8c17a084 100644 --- a/CHANGELOG-v3.md +++ b/CHANGELOG-v3.md @@ -7,6 +7,9 @@ - Craft.MatrixInput now fires an `afterInit` event after initialization. ([#3375](https://github.com/craftcms/cms/pull/3375)) - Craft.MatrixInput now fires an `blockAdded` event after adding a new block. ([#3375](https://github.com/craftcms/cms/pull/3375)) +### Fixed +- Fixed an error that could occur when acquiring a lock for a file path, if the `mutex` component was swapped out with `yii\mutex\MysqlMutex`. + ## 3.0.27.1 - 2018-10-12 ### Fixed diff --git a/src/helpers/FileHelper.php b/src/helpers/FileHelper.php index a1fdaeafa38..b1b6870b760 100644 --- a/src/helpers/FileHelper.php +++ b/src/helpers/FileHelper.php @@ -337,7 +337,11 @@ public static function writeToFile(string $file, string $contents, array $option } if ($lock) { - Craft::$app->getMutex()->acquire($file); + $mutex = Craft::$app->getMutex(); + $lockName = md5($file); + $mutex->acquire($lockName); + } else { + $lockName = $mutex = null; } $flags = 0; @@ -350,7 +354,7 @@ public static function writeToFile(string $file, string $contents, array $option } if ($lock) { - Craft::$app->getMutex()->release($file); + $mutex->release($lockName); } }