Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8899e31

Browse files
committed
Merge branch '2.2' into 2.3
* 2.2: [HttpFoundation] removed double-slashes (closes #8388) [HttpFoundation] tried to keep the original Request URI as much as possible to avoid different behavior between ::createFromGlobals() and ::create() [TwigBridge] fixed form rendering when used in a template with dynamic inheritance
2 parents 097b376 + b591419 commit 8899e31

File tree

6 files changed

+34
-4
lines changed

6 files changed

+34
-4
lines changed

src/Symfony/Bridge/Twig/Form/TwigRendererEngine.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,8 @@ protected function loadResourcesFromTheme($cacheKey, &$theme)
167167
// theme is a reference and we don't want to change it.
168168
$currentTheme = $theme;
169169

170+
$context = $this->environment->mergeGlobals(array());
171+
170172
// The do loop takes care of template inheritance.
171173
// Add blocks from all templates in the inheritance tree, but avoid
172174
// overriding blocks already set.
@@ -178,6 +180,6 @@ protected function loadResourcesFromTheme($cacheKey, &$theme)
178180
$this->resources[$cacheKey][$block] = $blockData;
179181
}
180182
}
181-
} while (false !== $currentTheme = $currentTheme->getParent(array()));
183+
} while (false !== $currentTheme = $currentTheme->getParent($context));
182184
}
183185
}

src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionDivLayoutTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ protected function setUp()
6464
$environment = new \Twig_Environment($loader, array('strict_variables' => true));
6565
$environment->addExtension(new TranslationExtension(new StubTranslator()));
6666
$environment->addGlobal('global', '');
67+
// the value can be any template that exists
68+
$environment->addGlobal('dynamic_template_name', 'child_label');
6769
$environment->addExtension($this->extension);
6870

6971
$this->extension->initRuntime($environment);
@@ -106,6 +108,18 @@ public function testThemeBlockInheritanceUsingExtend()
106108
);
107109
}
108110

111+
public function testThemeBlockInheritanceUsingDynamicExtend()
112+
{
113+
$view = $this->factory
114+
->createNamed('name', 'email')
115+
->createView()
116+
;
117+
118+
$renderer = $this->extension->renderer;
119+
$renderer->setTheme($view, array('page_dynamic_extends.html.twig'));
120+
$renderer->searchAndRenderBlock($view, 'row');
121+
}
122+
109123
public function isSelectedChoiceProvider()
110124
{
111125
// The commented cases should not be necessary anymore, because the
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{% extends dynamic_template_name ~ '.html.twig' %}

src/Symfony/Component/HttpFoundation/File/File.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ protected function getTargetFile($directory, $name = null)
137137
throw new FileException(sprintf('Unable to write in the "%s" directory', $directory));
138138
}
139139

140-
$target = $directory.DIRECTORY_SEPARATOR.(null === $name ? $this->getBasename() : $this->getName($name));
140+
$target = trim($directory, '/\\').DIRECTORY_SEPARATOR.(null === $name ? $this->getBasename() : $this->getName($name));
141141

142142
return new File($target, false);
143143
}

src/Symfony/Component/HttpFoundation/Request.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -346,11 +346,20 @@ public static function create($uri, $method = 'GET', $parameters = array(), $coo
346346
break;
347347
}
348348

349+
$queryString = '';
349350
if (isset($components['query'])) {
350351
parse_str(html_entity_decode($components['query']), $qs);
351-
$query = array_replace($qs, $query);
352+
353+
if ($query) {
354+
$query = array_replace($qs, $query);
355+
$queryString = http_build_query($query, '', '&');
356+
} else {
357+
$query = $qs;
358+
$queryString = $components['query'];
359+
}
360+
} elseif ($query) {
361+
$queryString = http_build_query($query, '', '&');
352362
}
353-
$queryString = http_build_query($query, '', '&');
354363

355364
$server['REQUEST_URI'] = $components['path'].('' !== $queryString ? '?'.$queryString : '');
356365
$server['QUERY_STRING'] = $queryString;

src/Symfony/Component/HttpFoundation/Tests/RequestTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,10 @@ public function testCreate()
211211
$this->assertEquals('testnopass', $request->getUser());
212212
$this->assertNull($request->getPassword());
213213
$this->assertFalse($request->isSecure());
214+
215+
$request = Request::create('http://test.com/?foo');
216+
$this->assertEquals('/?foo', $request->getRequestUri());
217+
$this->assertEquals(array('foo' => ''), $request->query->all());
214218
}
215219

216220
/**

0 commit comments

Comments
 (0)