diff --git a/src/Symfony/Bridge/Twig/Form/TwigRendererEngine.php b/src/Symfony/Bridge/Twig/Form/TwigRendererEngine.php index 05beb31565..768a0816fd 100644 --- a/src/Symfony/Bridge/Twig/Form/TwigRendererEngine.php +++ b/src/Symfony/Bridge/Twig/Form/TwigRendererEngine.php @@ -167,6 +167,8 @@ class TwigRendererEngine extends AbstractRendererEngine implements TwigRendererE // theme is a reference and we don't want to change it. $currentTheme = $theme; + $context = $this->environment->mergeGlobals(array()); + // The do loop takes care of template inheritance. // Add blocks from all templates in the inheritance tree, but avoid // overriding blocks already set. @@ -178,6 +180,6 @@ class TwigRendererEngine extends AbstractRendererEngine implements TwigRendererE $this->resources[$cacheKey][$block] = $blockData; } } - } while (false !== $currentTheme = $currentTheme->getParent(array())); + } while (false !== $currentTheme = $currentTheme->getParent($context)); } } diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionDivLayoutTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionDivLayoutTest.php index c5c134bc1c..5eb67ea730 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionDivLayoutTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionDivLayoutTest.php @@ -64,6 +64,8 @@ class FormExtensionDivLayoutTest extends AbstractDivLayoutTest $environment = new \Twig_Environment($loader, array('strict_variables' => true)); $environment->addExtension(new TranslationExtension(new StubTranslator())); $environment->addGlobal('global', ''); + // the value can be any template that exists + $environment->addGlobal('dynamic_template_name', 'child_label'); $environment->addExtension($this->extension); $this->extension->initRuntime($environment); @@ -106,6 +108,18 @@ class FormExtensionDivLayoutTest extends AbstractDivLayoutTest ); } + public function testThemeBlockInheritanceUsingDynamicExtend() + { + $view = $this->factory + ->createNamed('name', 'email') + ->createView() + ; + + $renderer = $this->extension->renderer; + $renderer->setTheme($view, array('page_dynamic_extends.html.twig')); + $renderer->searchAndRenderBlock($view, 'row'); + } + public function isSelectedChoiceProvider() { // The commented cases should not be necessary anymore, because the diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/page_dynamic_extends.html.twig b/src/Symfony/Bridge/Twig/Tests/Extension/page_dynamic_extends.html.twig new file mode 100644 index 0000000000..ac166b7b60 --- /dev/null +++ b/src/Symfony/Bridge/Twig/Tests/Extension/page_dynamic_extends.html.twig @@ -0,0 +1 @@ +{% extends dynamic_template_name ~ '.html.twig' %} diff --git a/src/Symfony/Component/HttpFoundation/File/File.php b/src/Symfony/Component/HttpFoundation/File/File.php index 9002b51085..0646b61aa3 100644 --- a/src/Symfony/Component/HttpFoundation/File/File.php +++ b/src/Symfony/Component/HttpFoundation/File/File.php @@ -137,7 +137,7 @@ class File extends \SplFileInfo throw new FileException(sprintf('Unable to write in the "%s" directory', $directory)); } - $target = $directory.DIRECTORY_SEPARATOR.(null === $name ? $this->getBasename() : $this->getName($name)); + $target = trim($directory, '/\\').DIRECTORY_SEPARATOR.(null === $name ? $this->getBasename() : $this->getName($name)); return new File($target, false); } diff --git a/src/Symfony/Component/HttpFoundation/Request.php b/src/Symfony/Component/HttpFoundation/Request.php index 0e7dfd8b32..999a066de1 100644 --- a/src/Symfony/Component/HttpFoundation/Request.php +++ b/src/Symfony/Component/HttpFoundation/Request.php @@ -346,11 +346,20 @@ class Request break; } + $queryString = ''; if (isset($components['query'])) { parse_str(html_entity_decode($components['query']), $qs); - $query = array_replace($qs, $query); + + if ($query) { + $query = array_replace($qs, $query); + $queryString = http_build_query($query, '', '&'); + } else { + $query = $qs; + $queryString = $components['query']; + } + } elseif ($query) { + $queryString = http_build_query($query, '', '&'); } - $queryString = http_build_query($query, '', '&'); $server['REQUEST_URI'] = $components['path'].('' !== $queryString ? '?'.$queryString : ''); $server['QUERY_STRING'] = $queryString; diff --git a/src/Symfony/Component/HttpFoundation/Tests/RequestTest.php b/src/Symfony/Component/HttpFoundation/Tests/RequestTest.php index 9aea715112..f09ddd348b 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/RequestTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/RequestTest.php @@ -211,6 +211,10 @@ class RequestTest extends \PHPUnit_Framework_TestCase $this->assertEquals('testnopass', $request->getUser()); $this->assertNull($request->getPassword()); $this->assertFalse($request->isSecure()); + + $request = Request::create('http://test.com/?foo'); + $this->assertEquals('/?foo', $request->getRequestUri()); + $this->assertEquals(array('foo' => ''), $request->query->all()); } /**