瀏覽代碼

Fixed fatal error when the permission to write cache files was denied

Fabien Potencier 15 年之前
父節點
當前提交
4a742138e6

+ 4 - 1
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);
     }
 }

+ 4 - 1
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);
     }
 

+ 4 - 1
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);
     }
 }