From 5488540f6ba0aa63d3cb86df0e60bbddc976e0f0 Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Fri, 21 Apr 2023 14:06:14 +0200 Subject: [PATCH] [Cache] Prevent unnecessary file IO --- src/Symfony/Component/Cache/Adapter/PhpFilesAdapter.php | 2 +- src/Symfony/Component/Cache/Traits/FilesystemTrait.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/Cache/Adapter/PhpFilesAdapter.php b/src/Symfony/Component/Cache/Adapter/PhpFilesAdapter.php index d104530c0d337..b08b7c749ba66 100644 --- a/src/Symfony/Component/Cache/Adapter/PhpFilesAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/PhpFilesAdapter.php @@ -82,7 +82,7 @@ public function prune(): bool } if ($time >= $expiresAt) { - $pruned = $this->doUnlink($file) && !file_exists($file) && $pruned; + $pruned = $this->doUnlink($file) && $pruned && !file_exists($file); } } } finally { diff --git a/src/Symfony/Component/Cache/Traits/FilesystemTrait.php b/src/Symfony/Component/Cache/Traits/FilesystemTrait.php index b1464f0c5026e..fb1b05b79c7a4 100644 --- a/src/Symfony/Component/Cache/Traits/FilesystemTrait.php +++ b/src/Symfony/Component/Cache/Traits/FilesystemTrait.php @@ -38,7 +38,7 @@ public function prune(): bool if (($expiresAt = (int) fgets($h)) && $time >= $expiresAt) { fclose($h); - $pruned = @unlink($file) && !file_exists($file) && $pruned; + $pruned = @unlink($file) && $pruned && !file_exists($file); } else { fclose($h); }