avoid writing template file if an error occurs

git-svn-id: http://svn.twig-project.org/trunk@56 93ef8e89-cb99-4229-a87c-7fa0fa45744b
This commit is contained in:
fabien
2009-10-15 06:06:17 +00:00
parent d11a3307ea
commit 6f535bc859
2 changed files with 10 additions and 9 deletions
+1
View File
@@ -1,5 +1,6 @@
* 0.9.2-DEV
* avoid writing template file if an error occurs
* added $ escaping when outputting raw strings
* enhanced some error messages to ease debugging
* fixed empty cache files when the template contains an error
+9 -9
View File
@@ -78,19 +78,19 @@ abstract class Twig_Loader implements Twig_LoaderInterface
$cache = $this->getCacheFilename($name);
if (!file_exists($cache) || false === $mtime || ($this->autoReload && (filemtime($cache) < $mtime)))
{
$fp = @fopen($cache, 'wb');
if (!$fp)
{
$this->evalString($template, $name);
return $cls;
}
// compile first to avoid empty files when an Exception occurs
$content = $this->compile($template, $name);
file_put_contents($cache, $content);
$fp = @fopen($cache, 'wb');
if (!$fp)
{
eval('?>'.$content);
return $cls;
}
fclose($fp);
file_put_contents($cache, $content);
}
require_once $cache;