From 92b715f5c870d6f13ffd485f7884b67750d575bd Mon Sep 17 00:00:00 2001 From: fabien Date: Wed, 14 Oct 2009 14:25:20 +0000 Subject: [PATCH] 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 --- CHANGELOG | 2 ++ lib/Twig/Loader.php | 6 +++++- 2 files changed, 7 insertions(+), 1 deletions(-) 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); } -- 1.7.2.5