Skip to content

Commit

Permalink
Gracefully handle gzuncompress issues in environments where PHP error…
Browse files Browse the repository at this point in the history
…s converted to exceptions
  • Loading branch information
DivineOmega committed Dec 31, 2018
1 parent e936b57 commit 6f75be7
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/DOFileCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,16 @@ public function get($key)
$cacheFileData = file_get_contents($filePath);

if ($this->config['gzipCompression']) {
$cacheFileData = gzuncompress($cacheFileData);
try {
$cacheFileData = gzuncompress($cacheFileData);
} catch (\Exception $e) {
$cacheFileData = false;
}
}

$cacheObj = json_decode($cacheFileData);

// Unable to decode JSON (could happen if compression was turned off while compressed caches still exist)
// Unable to decode JSON
if ($cacheObj === null) {
return false;
}
Expand Down

0 comments on commit 6f75be7

Please sign in to comment.