From 4a742138e67f179181376ede6e9324c445c0d9f1 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 23 Jun 2010 07:35:46 +0200 Subject: [PATCH] Fixed fatal error when the permission to write cache files was denied --- src/Symfony/Foundation/ClassCollectionLoader.php | 5 ++++- src/Symfony/Foundation/Kernel.php | 5 ++++- src/Symfony/Foundation/bootstrap.php | 5 ++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Foundation/ClassCollectionLoader.php b/src/Symfony/Foundation/ClassCollectionLoader.php index 2a0d1c379e..23f62e32bc 100644 --- a/src/Symfony/Foundation/ClassCollectionLoader.php +++ b/src/Symfony/Foundation/ClassCollectionLoader.php @@ -95,7 +95,10 @@ class ClassCollectionLoader die(sprintf('Failed to write cache file "%s" (cache corrupted).', $tmpFile)); } - @rename($tmpFile, $file); + if (!@rename($tmpFile, $file)) { + throw new \RuntimeException(sprintf('Failed to write cache file "%s".', $file)); + } + chmod($file, 0644); } } diff --git a/src/Symfony/Foundation/Kernel.php b/src/Symfony/Foundation/Kernel.php index 77ca3d6530..7b8d7bd05f 100644 --- a/src/Symfony/Foundation/Kernel.php +++ b/src/Symfony/Foundation/Kernel.php @@ -427,7 +427,10 @@ abstract class Kernel implements HttpKernelInterface, \Serializable die(sprintf('Failed to write cache file "%s" (cache corrupted).', $tmpFile)); } - @rename($tmpFile, $file); + if (!@rename($tmpFile, $file)) { + throw new \RuntimeException(sprintf('Failed to write cache file "%s".', $file)); + } + chmod($file, 0644); } diff --git a/src/Symfony/Foundation/bootstrap.php b/src/Symfony/Foundation/bootstrap.php index 258ae3f3a0..0c2bd34f6d 100644 --- a/src/Symfony/Foundation/bootstrap.php +++ b/src/Symfony/Foundation/bootstrap.php @@ -384,7 +384,10 @@ class ClassCollectionLoader die(sprintf('Failed to write cache file "%s" (cache corrupted).', $tmpFile)); } - @rename($tmpFile, $file); + if (!@rename($tmpFile, $file)) { + throw new \RuntimeException(sprintf('Failed to write cache file "%s".', $file)); + } + chmod($file, 0644); } }