diff --git a/lib/Twig/Loader/Filesystem.php b/lib/Twig/Loader/Filesystem.php index 62142f6196..2d6170c360 100644 --- a/lib/Twig/Loader/Filesystem.php +++ b/lib/Twig/Loader/Filesystem.php @@ -143,7 +143,8 @@ public function getCacheKey($name) */ public function exists($name) { - $name = (string) $name; + $name = $this->normalizeName($name); + if (isset($this->cache[$name])) { return true; } @@ -164,15 +165,10 @@ public function isFresh($name, $time) { return filemtime($this->findTemplate($name)) <= $time; } - - protected function normalize($name) - { - return preg_replace('#/{2,}#', '/', strtr((string) $name, '\\', '/')); - } protected function findTemplate($name) { - $name = $this->normalize($name); + $name = $this->normalizeName($name); if (isset($this->cache[$name])) { return $this->cache[$name]; @@ -204,6 +200,11 @@ protected function findTemplate($name) throw new Twig_Error_Loader(sprintf('Unable to find template "%s" (looked into: %s).', $name, implode(', ', $this->paths[$namespace]))); } + protected function normalizeName($name) + { + return preg_replace('#/{2,}#', '/', strtr((string) $name, '\\', '/')); + } + protected function validateName($name) { if (false !== strpos($name, "\0")) {