FIX #1596 FileSystem::findTemplate now applies realpath on the absolute ...

This commit is contained in:
Xavier Leune
2015-01-16 10:32:06 +01:00
committed by Fabien Potencier
parent e999532003
commit 5074114bbb
4 changed files with 12 additions and 1 deletions
+2 -1
View File
@@ -1,6 +1,7 @@
* 1.17.1 (2015-XX-XX)
* n/a
* The template filename have realpath applied before returning it. In this way we have the same path between the
resolution of Twig and Twing bundle cache warmup, allowing to have one cache key.
* 1.17.0 (2015-01-14)
+3
View File
@@ -183,6 +183,9 @@ class Twig_Loader_Filesystem implements Twig_LoaderInterface, Twig_ExistsLoaderI
}
foreach ($this->paths[$namespace] as $path) {
if (false !== $realpath = realpath($path.'/'.$shortname)) {
return $this->cache[$name] = $realpath;
}
if (is_file($path.'/'.$shortname)) {
return $this->cache[$name] = $path.'/'.$shortname;
}
@@ -60,6 +60,7 @@ class Twig_Tests_Loader_FilesystemTest extends PHPUnit_Framework_TestCase
$loader->addPath($basePath.'/named_ter', 'named');
$loader->addPath($basePath.'/normal_ter');
$loader->prependPath($basePath.'/normal_final');
$loader->prependPath($basePath.'/named/../named_quater', 'named');
$loader->prependPath($basePath.'/named_final', 'named');
$this->assertEquals(array(
@@ -70,11 +71,16 @@ class Twig_Tests_Loader_FilesystemTest extends PHPUnit_Framework_TestCase
), $loader->getPaths());
$this->assertEquals(array(
$basePath.'/named_final',
$basePath.'/named/../named_quater',
$basePath.'/named',
$basePath.'/named_bis',
$basePath.'/named_ter',
), $loader->getPaths('named'));
$this->assertEquals(
$basePath.'/named_quater/named_absolute.html',
$loader->getCacheKey('@named/named_absolute.html')
);
$this->assertEquals("path (final)\n", $loader->getSource('index.html'));
$this->assertEquals("path (final)\n", $loader->getSource('@__main__/index.html'));
$this->assertEquals("named path (final)\n", $loader->getSource('@named/index.html'));
@@ -0,0 +1 @@
named path (quater)