Skip to content

Commit

Permalink
The fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Slamdunk committed Apr 19, 2018
1 parent 3ed50f9 commit b8f4b71
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions framework/caching/FileCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,12 @@ protected function setValue($key, $value, $duration)
if ($this->directoryLevel > 0) {
@FileHelper::createDirectory(dirname($cacheFile), $this->dirMode, true);
}
// If ownership differs the touch call will fail, so we try to
// rebuild the file from scratch by deleting it first
// https://github.com/yiisoft/yii2/pull/16120
if (is_file($cacheFile) && fileowner($cacheFile) !== posix_geteuid()) {
@unlink($cacheFile);
}
if (@file_put_contents($cacheFile, $value, LOCK_EX) !== false) {
if ($this->fileMode !== null) {
@chmod($cacheFile, $this->fileMode);
Expand Down

0 comments on commit b8f4b71

Please sign in to comment.