|
@@ -462,21 +462,13 @@ abstract class Kernel implements HttpKernelInterface, \Serializable
|
|
|
protected function writeCacheFile($file, $content)
|
|
|
{
|
|
|
$tmpFile = tempnam(dirname($file), basename($file));
|
|
|
- if (!$fp = @fopen($tmpFile, 'wb')) {
|
|
|
- die(sprintf('Failed to write cache file "%s".', $tmpFile));
|
|
|
- }
|
|
|
- @fwrite($fp, $content);
|
|
|
- @fclose($fp);
|
|
|
-
|
|
|
- if ($content != file_get_contents($tmpFile)) {
|
|
|
- die(sprintf('Failed to write cache file "%s" (cache corrupted).', $tmpFile));
|
|
|
- }
|
|
|
+ if (false !== @file_put_contents($tmpFile, $content) && @rename($tmpFile, $file)) {
|
|
|
+ chmod($file, 0644);
|
|
|
|
|
|
- if (!@rename($tmpFile, $file)) {
|
|
|
- throw new \RuntimeException(sprintf('Failed to write cache file "%s".', $file));
|
|
|
+ return;
|
|
|
}
|
|
|
|
|
|
- chmod($file, 0644);
|
|
|
+ throw new \RuntimeException(sprintf('Failed to write cache file "%s".', $file));
|
|
|
}
|
|
|
|
|
|
public function serialize()
|