mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-18 13:26:37 +00:00
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:
@@ -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
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user