From: Fabien Potencier Date: Fri, 27 Dec 2013 14:37:02 +0000 (+0100) Subject: fixed Filesystem::exists() to normalize the template name before checking the cache X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=27f3e0fc1efd1dbaf6d10598d148d7ec3070b51d;p=web%2Fkonrad%2Ftwig.git fixed Filesystem::exists() to normalize the template name before checking the cache --- diff --git a/lib/Twig/Loader/Filesystem.php b/lib/Twig/Loader/Filesystem.php index 62142f6..2d6170c 100644 --- a/lib/Twig/Loader/Filesystem.php +++ b/lib/Twig/Loader/Filesystem.php @@ -143,7 +143,8 @@ class Twig_Loader_Filesystem implements Twig_LoaderInterface, Twig_ExistsLoaderI */ public function exists($name) { - $name = (string) $name; + $name = $this->normalizeName($name); + if (isset($this->cache[$name])) { return true; } @@ -164,15 +165,10 @@ class Twig_Loader_Filesystem implements Twig_LoaderInterface, Twig_ExistsLoaderI { 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 @@ class Twig_Loader_Filesystem implements Twig_LoaderInterface, Twig_ExistsLoaderI 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")) {