Skip to content

Commit 6f75be7

Browse files
committed
Gracefully handle gzuncompress issues in environments where PHP errors converted to exceptions
1 parent e936b57 commit 6f75be7

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/DOFileCache.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,16 @@ public function get($key)
105105
$cacheFileData = file_get_contents($filePath);
106106

107107
if ($this->config['gzipCompression']) {
108-
$cacheFileData = gzuncompress($cacheFileData);
108+
try {
109+
$cacheFileData = gzuncompress($cacheFileData);
110+
} catch (\Exception $e) {
111+
$cacheFileData = false;
112+
}
109113
}
110114

111115
$cacheObj = json_decode($cacheFileData);
112116

113-
// Unable to decode JSON (could happen if compression was turned off while compressed caches still exist)
117+
// Unable to decode JSON
114118
if ($cacheObj === null) {
115119
return false;
116120
}

0 commit comments

Comments
 (0)