From: fabien Date: Wed, 14 Oct 2009 14:25:20 +0000 (+0000) Subject: fixed empty cache files when the template contains an error (closes #8) X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=92b715f5c870d6f13ffd485f7884b67750d575bd;p=konrad%2Ftwig.git fixed empty cache files when the template contains an error (closes #8) git-svn-id: http://svn.twig-project.org/trunk@53 93ef8e89-cb99-4229-a87c-7fa0fa45744b --- diff --git a/CHANGELOG b/CHANGELOG index 63b7cec..d3cec98 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 db63a58..57ef9c4 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); }