diff --git a/core/lib/Drupal/Core/Template/TwigEnvironment.php b/core/lib/Drupal/Core/Template/TwigEnvironment.php index 762271f..06f3def 100644 --- a/core/lib/Drupal/Core/Template/TwigEnvironment.php +++ b/core/lib/Drupal/Core/Template/TwigEnvironment.php @@ -10,7 +10,6 @@ use Drupal\Core\PhpStorage\PhpStorageFactory; use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Extension\ThemeHandlerInterface; -use LogicException; /** * A class that defines a Twig environment for Drupal. @@ -75,11 +74,11 @@ public function __construct(\Twig_LoaderInterface $loader = NULL, $options = arr /** * Checks if the compiled template needs an update. */ - public function needsUpdate($cache_filename, $name) { + public function isFresh($cache_filename, $name) { $cid = 'twig:' . $cache_filename; $obj = $this->cache_object->get($cid); $mtime = isset($obj->data) ? $obj->data : FALSE; - return $mtime !== FALSE && !$this->isTemplateFresh($name, $mtime); + return $mtime === FALSE || $this->isTemplateFresh($name, $mtime); } /** @@ -106,8 +105,8 @@ public function updateCompiledTemplate($cache_filename, $name, $inline = FALSE) * @return \Twig_LoaderInterface A Twig_LoaderInterface instance */ public function getLoader($inline = FALSE) { - if (NULL === $this->loader) { - throw new LogicException('You must set a loader first.'); + if (!isset($this->loader)) { + throw new \LogicException('You must set a loader first.'); } return $inline ? $this->stringLoader : $this->loader; } @@ -153,7 +152,7 @@ public function loadTemplate($name, $index = NULL, $inline = FALSE) { // If autoreload is on, check that the template has not been // modified since the last compilation. - if ($this->isAutoReload() && $this->needsUpdate($cache_filename, $name)) { + if ($this->isAutoReload() && !$this->isFresh($cache_filename, $name)) { $this->updateCompiledTemplate($cache_filename, $name, $inline); }