diff --git a/src/Cache/FileCache.php b/src/Cache/FileCache.php index a027439..a2e02e7 100644 --- a/src/Cache/FileCache.php +++ b/src/Cache/FileCache.php @@ -142,13 +142,14 @@ public function get(string $key, mixed $default = null): mixed return $default; // Get the data from the file and unserialize it - $data = unserialize(file_get_contents($cache_file_path)); + $data = @unserialize(file_get_contents($cache_file_path)); if ($data === false) return $default; // If the cached entry is expired and does not have any ETag, remove it. - if ($data->expired() && ! $data->hasHeader('ETag')) { + // The false case occur if a cache save is incomplete so the unserialize fails. + if ($data === false || $data->expired() && ! $data->hasHeader('ETag')) { $this->delete($key); return $default;