diff --git a/CHANGELOG b/CHANGELOG index 63b7cec27..d3cec9819 100644 --- 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 diff --git a/lib/Twig/Loader.php b/lib/Twig/Loader.php index db63a58d1..57ef9c4a7 100644 --- a/lib/Twig/Loader.php +++ b/lib/Twig/Loader.php @@ -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); }