diff --git a/src/Symfony/Component/Cache/Traits/FilesystemCommonTrait.php b/src/Symfony/Component/Cache/Traits/FilesystemCommonTrait.php index c06cc309a6b3f..16e768990b942 100644 --- a/src/Symfony/Component/Cache/Traits/FilesystemCommonTrait.php +++ b/src/Symfony/Component/Cache/Traits/FilesystemCommonTrait.php @@ -90,6 +90,7 @@ protected function doUnlink(string $file) private function write(string $file, string $data, int $expiresAt = null) { + $unlink = false; set_error_handler(__CLASS__.'::throwError'); try { if (null === $this->tmp) { @@ -107,14 +108,22 @@ private function write(string $file, string $data, int $expiresAt = null) } fwrite($h, $data); fclose($h); + $unlink = true; if (null !== $expiresAt) { touch($this->tmp, $expiresAt ?: time() + 31556952); // 1 year in seconds } - return rename($this->tmp, $file); + $success = rename($this->tmp, $file); + $unlink = !$success; + + return $success; } finally { restore_error_handler(); + + if ($unlink) { + @unlink($this->tmp); + } } }
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: