Skip to content

Commit

Permalink
fix(file_cache): if write failure, produce log record instead of exce…
Browse files Browse the repository at this point in the history
…ption
  • Loading branch information
dvikan committed Nov 28, 2024
1 parent 88ccc60 commit 497456c
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions caches/FileCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,13 @@ public function set($key, $value, int $ttl = null): void
];
$cacheFile = $this->createCacheFile($key);
$bytes = file_put_contents($cacheFile, serialize($item));
// todo: Consider tightening the permissions of the created file. It usually allow others to read, depending on umask

// TODO: Consider tightening the permissions of the created file.
// It usually allow others to read, depending on umask

if ($bytes === false) {
// Consider just logging the error here
throw new \Exception(sprintf('Failed to write to: %s', $cacheFile));
// Typically means no disk space remaining
$this->logger->warning(sprintf('Failed to write to: %s', $cacheFile));
}
}

Expand Down

0 comments on commit 497456c

Please sign in to comment.