From 497456c16efd85743809704a397e8c9669e9a2aa Mon Sep 17 00:00:00 2001 From: Dag Date: Thu, 28 Nov 2024 03:49:09 +0100 Subject: [PATCH] fix(file_cache): if write failure, produce log record instead of exception --- caches/FileCache.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/caches/FileCache.php b/caches/FileCache.php index ff939beaeff..24a9872fe6b 100644 --- a/caches/FileCache.php +++ b/caches/FileCache.php @@ -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)); } }