From b4259a6bf369e27ec22ad6b60bea27c355c70766 Mon Sep 17 00:00:00 2001 From: Lars Strojny Date: Sat, 10 Feb 2018 12:14:07 +0100 Subject: [PATCH] Use 0 for unlimited expiry --- .../Component/Cache/Traits/FilesystemTrait.php | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/Symfony/Component/Cache/Traits/FilesystemTrait.php b/src/Symfony/Component/Cache/Traits/FilesystemTrait.php index bcb940cb0f754..23974b3bc5487 100644 --- a/src/Symfony/Component/Cache/Traits/FilesystemTrait.php +++ b/src/Symfony/Component/Cache/Traits/FilesystemTrait.php @@ -36,9 +36,9 @@ public function prune() continue; } - if ($time >= (int) $expiresAt = fgets($h)) { + if (($expiresAt = (int) fgets($h)) && $time >= $expiresAt) { fclose($h); - $pruned = isset($expiresAt[0]) && @unlink($file) && !file_exists($file) && $pruned; + $pruned = @unlink($file) && !file_exists($file) && $pruned; } else { fclose($h); } @@ -60,11 +60,9 @@ protected function doFetch(array $ids) if (!file_exists($file) || !$h = @fopen($file, 'rb')) { continue; } - if ($now >= (int) $expiresAt = fgets($h)) { + if (($expiresAt = (int) fgets($h)) && $now >= $expiresAt) { fclose($h); - if (isset($expiresAt[0])) { - @unlink($file); - } + @unlink($file); } else { $i = rawurldecode(rtrim(fgets($h))); $value = stream_get_contents($h); @@ -94,7 +92,7 @@ protected function doHave($id) protected function doSave(array $values, $lifetime) { $ok = true; - $expiresAt = time() + ($lifetime ?: 31557600); // 31557600s = 1 year + $expiresAt = $lifetime ? (time() + $lifetime) : 0; foreach ($values as $id => $value) { $ok = $this->write($this->getFile($id, true), $expiresAt."\n".rawurlencode($id)."\n".serialize($value), $expiresAt) && $ok; pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy