fixed empty cache files when the template contains an error (closes #8)
authorfabien <fabien@93ef8e89-cb99-4229-a87c-7fa0fa45744b>
Wed, 14 Oct 2009 14:25:20 +0000 (14:25 +0000)
committerfabien <fabien@93ef8e89-cb99-4229-a87c-7fa0fa45744b>
Wed, 14 Oct 2009 14:25:20 +0000 (14:25 +0000)
git-svn-id: http://svn.twig-project.org/trunk@53 93ef8e89-cb99-4229-a87c-7fa0fa45744b

CHANGELOG
lib/Twig/Loader.php

index 63b7cec..d3cec98 100644 (file)
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,5 +1,7 @@
 * 0.9.2-DEV
 
+ * fixed empty cache files when the template contains an error
+
 * 0.9.1 (2009-10-14)
 
   * fixed a bug in PHP 5.2.6
index db63a58..57ef9c4 100644 (file)
@@ -85,7 +85,11 @@ abstract class Twig_Loader implements Twig_LoaderInterface
 
         return $cls;
       }
-      file_put_contents($cache, $this->compile($template, $name));
+
+      // compile first to avoid empty files when an Exception occurs
+      $content = $this->compile($template, $name);
+
+      file_put_contents($cache, $content);
       fclose($fp);
     }