Skip to content

Commit 3a027ba

Browse files
committed
Merge branch '2.3' into 2.7
* 2.3: fixed CS [BrowserKit] Corrected HTTP_HOST logic symfony#15398 resolve aliases in factory services Remove invalid CSS white-space value Fix FileSystem tests on Windows
2 parents da16d15 + 828fba4 commit 3a027ba

File tree

8 files changed

+55
-39
lines changed

8 files changed

+55
-39
lines changed

src/Symfony/Bundle/FrameworkBundle/Resources/public/css/exception.css

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
padding: 5px 4px;
88
list-style-type: decimal;
99
margin-left: 20px;
10-
white-space: break-word;
1110
}
1211
.sf-reset #logs .traces li.error {
1312
font-style: normal;

src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/exception.css.twig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
padding: 5px 4px;
88
list-style-type: decimal;
99
margin-left: 20px;
10-
white-space: break-word;
1110
}
1211
.sf-reset #logs .traces li.error {
1312
font-style: normal;

src/Symfony/Component/BrowserKit/Client.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ public function insulate($insulated = true)
103103
public function setServerParameters(array $server)
104104
{
105105
$this->server = array_merge(array(
106-
'HTTP_HOST' => 'localhost',
107106
'HTTP_USER_AGENT' => 'Symfony2 BrowserKit',
108107
), $server);
109108
}
@@ -266,21 +265,20 @@ public function request($method, $uri, array $parameters = array(), array $files
266265

267266
$uri = $this->getAbsoluteUri($uri);
268267

269-
if (!empty($server['HTTP_HOST'])) {
270-
$uri = preg_replace('{^(https?\://)'.preg_quote($this->extractHost($uri)).'}', '${1}'.$server['HTTP_HOST'], $uri);
271-
}
268+
$server = array_merge($this->server, $server);
272269

273270
if (isset($server['HTTPS'])) {
274271
$uri = preg_replace('{^'.parse_url($uri, PHP_URL_SCHEME).'}', $server['HTTPS'] ? 'https' : 'http', $uri);
275272
}
276273

277-
$server = array_merge($this->server, $server);
278-
279274
if (!$this->history->isEmpty()) {
280275
$server['HTTP_REFERER'] = $this->history->current()->getUri();
281276
}
282277

283-
$server['HTTP_HOST'] = $this->extractHost($uri);
278+
if (empty($server['HTTP_HOST'])) {
279+
$server['HTTP_HOST'] = $this->extractHost($uri);
280+
}
281+
284282
$server['HTTPS'] = 'https' == parse_url($uri, PHP_URL_SCHEME);
285283

286284
$this->internalRequest = new Request($uri, $method, $parameters, $files, $this->cookieJar->allValues($uri), $server, $content);

src/Symfony/Component/BrowserKit/Tests/ClientTest.php

Lines changed: 9 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,14 @@ public function testGetRequest()
9393
$this->assertEquals('http://example.com/', $client->getRequest()->getUri(), '->getCrawler() returns the Request of the last request');
9494
}
9595

96-
public function testGetRequestWithIpAsHost()
96+
public function testGetRequestWithIpAsHttpHost()
9797
{
9898
$client = new TestClient();
9999
$client->request('GET', 'https://example.com/foo', array(), array(), array('HTTP_HOST' => '127.0.0.1'));
100100

101-
$this->assertEquals('https://127.0.0.1/foo', $client->getRequest()->getUri());
101+
$this->assertEquals('https://example.com/foo', $client->getRequest()->getUri());
102+
$headers = $client->getRequest()->getServer();
103+
$this->assertEquals('127.0.0.1', $headers['HTTP_HOST']);
102104
}
103105

104106
public function testGetResponse()
@@ -212,24 +214,6 @@ public function testRequestURIConversion()
212214
$this->assertEquals('http://www.example.com/http', $client->getRequest()->getUri(), '->request() uses the previous request for relative URLs');
213215
}
214216

215-
public function testRequestURIConversionByServerHost()
216-
{
217-
$client = new TestClient();
218-
219-
$server = array('HTTP_HOST' => 'www.exampl+e.com:8000');
220-
$parameters = array();
221-
$files = array();
222-
223-
$client->request('GET', 'http://exampl+e.com', $parameters, $files, $server);
224-
$this->assertEquals('http://www.exampl+e.com:8000', $client->getRequest()->getUri(), '->request() uses HTTP_HOST to add port');
225-
226-
$client->request('GET', 'http://exampl+e.com:8888', $parameters, $files, $server);
227-
$this->assertEquals('http://www.exampl+e.com:8000', $client->getRequest()->getUri(), '->request() uses HTTP_HOST to modify existing port');
228-
229-
$client->request('GET', 'http://exampl+e.com:8000', $parameters, $files, $server);
230-
$this->assertEquals('http://www.exampl+e.com:8000', $client->getRequest()->getUri(), '->request() uses HTTP_HOST respects correct set port');
231-
}
232-
233217
public function testRequestReferer()
234218
{
235219
$client = new TestClient();
@@ -572,7 +556,7 @@ public function testInsulatedRequests()
572556
public function testGetServerParameter()
573557
{
574558
$client = new TestClient();
575-
$this->assertEquals('localhost', $client->getServerParameter('HTTP_HOST'));
559+
$this->assertEquals('', $client->getServerParameter('HTTP_HOST'));
576560
$this->assertEquals('Symfony2 BrowserKit', $client->getServerParameter('HTTP_USER_AGENT'));
577561
$this->assertEquals('testvalue', $client->getServerParameter('testkey', 'testvalue'));
578562
}
@@ -581,7 +565,7 @@ public function testSetServerParameter()
581565
{
582566
$client = new TestClient();
583567

584-
$this->assertEquals('localhost', $client->getServerParameter('HTTP_HOST'));
568+
$this->assertEquals('', $client->getServerParameter('HTTP_HOST'));
585569
$this->assertEquals('Symfony2 BrowserKit', $client->getServerParameter('HTTP_USER_AGENT'));
586570

587571
$client->setServerParameter('HTTP_HOST', 'testhost');
@@ -595,7 +579,7 @@ public function testSetServerParameterInRequest()
595579
{
596580
$client = new TestClient();
597581

598-
$this->assertEquals('localhost', $client->getServerParameter('HTTP_HOST'));
582+
$this->assertEquals('', $client->getServerParameter('HTTP_HOST'));
599583
$this->assertEquals('Symfony2 BrowserKit', $client->getServerParameter('HTTP_USER_AGENT'));
600584

601585
$client->request('GET', 'https://www.example.com/https/www.example.com', array(), array(), array(
@@ -605,10 +589,10 @@ public function testSetServerParameterInRequest()
605589
'NEW_SERVER_KEY' => 'new-server-key-value',
606590
));
607591

608-
$this->assertEquals('localhost', $client->getServerParameter('HTTP_HOST'));
592+
$this->assertEquals('', $client->getServerParameter('HTTP_HOST'));
609593
$this->assertEquals('Symfony2 BrowserKit', $client->getServerParameter('HTTP_USER_AGENT'));
610594

611-
$this->assertEquals('http://testhost/https/www.example.com', $client->getRequest()->getUri());
595+
$this->assertEquals('http://www.example.com/https/www.example.com', $client->getRequest()->getUri());
612596

613597
$server = $client->getRequest()->getServer();
614598

src/Symfony/Component/DependencyInjection/Compiler/ResolveReferencesToAliasesPass.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ public function process(ContainerBuilder $container)
4444
$definition->setMethodCalls($this->processArguments($definition->getMethodCalls()));
4545
$definition->setProperties($this->processArguments($definition->getProperties()));
4646
$definition->setFactory($this->processFactory($definition->getFactory()));
47+
48+
if (null !== $factoryService = $definition->getFactoryService(false)) {
49+
$definition->setFactoryService($this->processFactoryService($factoryService));
50+
}
4751
}
4852

4953
foreach ($container->getAliases() as $id => $alias) {
@@ -78,6 +82,15 @@ private function processArguments(array $arguments)
7882
return $arguments;
7983
}
8084

85+
private function processFactoryService($factoryService)
86+
{
87+
if (null === $factoryService) {
88+
return;
89+
}
90+
91+
return $this->getDefinitionId($factoryService);
92+
}
93+
8194
private function processFactory($factory)
8295
{
8396
if (null === $factory || !is_array($factory) || !$factory[0] instanceof Reference) {

src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveReferencesToAliasesPassTest.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,24 @@ public function testResolveFactory()
8282
$this->assertSame('Factory', (string) $resolvedBarFactory[0]);
8383
}
8484

85+
/**
86+
* @group legacy
87+
*/
88+
public function testResolveFactoryService()
89+
{
90+
$container = new ContainerBuilder();
91+
$container->register('factory', 'Factory');
92+
$container->setAlias('factory_alias', new Alias('factory'));
93+
$foo = new Definition();
94+
$foo->setFactoryService('factory_alias');
95+
$foo->setFactoryMethod('createFoo');
96+
$container->setDefinition('foo', $foo);
97+
98+
$this->process($container);
99+
100+
$this->assertSame('factory', $foo->getFactoryService());
101+
}
102+
85103
protected function process(ContainerBuilder $container)
86104
{
87105
$pass = new ResolveReferencesToAliasesPass();

src/Symfony/Component/Filesystem/Tests/FilesystemTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -893,7 +893,7 @@ public function testMirrorCopiesLinks()
893893

894894
public function testMirrorCopiesLinkedDirectoryContents()
895895
{
896-
$this->markAsSkippedIfSymlinkIsMissing();
896+
$this->markAsSkippedIfSymlinkIsMissing(true);
897897

898898
$sourcePath = $this->workspace.DIRECTORY_SEPARATOR.'source'.DIRECTORY_SEPARATOR;
899899

@@ -913,7 +913,7 @@ public function testMirrorCopiesLinkedDirectoryContents()
913913

914914
public function testMirrorCopiesRelativeLinkedContents()
915915
{
916-
$this->markAsSkippedIfSymlinkIsMissing();
916+
$this->markAsSkippedIfSymlinkIsMissing(true);
917917

918918
$sourcePath = $this->workspace.DIRECTORY_SEPARATOR.'source'.DIRECTORY_SEPARATOR;
919919
$oldPath = getcwd();
@@ -1020,8 +1020,8 @@ public function testCopyShouldKeepExecutionPermission()
10201020
{
10211021
$this->markAsSkippedIfChmodIsMissing();
10221022

1023-
$sourceFilePath = $this->workspace.DIRECTORY_SEPARATOR.'copy_source_file';
1024-
$targetFilePath = $this->workspace.DIRECTORY_SEPARATOR.'copy_target_file';
1023+
$sourceFilePath = $this->workspace . DIRECTORY_SEPARATOR . 'copy_source_file';
1024+
$targetFilePath = $this->workspace . DIRECTORY_SEPARATOR . 'copy_target_file';
10251025

10261026
file_put_contents($sourceFilePath, 'SOURCE FILE');
10271027
chmod($sourceFilePath, 0745);

src/Symfony/Component/Filesystem/Tests/FilesystemTestCase.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ protected function getFileGroup($filepath)
9292
$this->markTestSkipped('Unable to retrieve file group name');
9393
}
9494

95-
protected function markAsSkippedIfSymlinkIsMissing()
95+
protected function markAsSkippedIfSymlinkIsMissing($relative = false)
9696
{
9797
if (!function_exists('symlink')) {
9898
$this->markTestSkipped('Function symlink is required.');
@@ -101,6 +101,11 @@ protected function markAsSkippedIfSymlinkIsMissing()
101101
if ('\\' === DIRECTORY_SEPARATOR && false === self::$symlinkOnWindows) {
102102
$this->markTestSkipped('symlink requires "Create symbolic links" privilege on Windows');
103103
}
104+
105+
// https://bugs.php.net/bug.php?id=69473
106+
if ($relative && '\\' === DIRECTORY_SEPARATOR && 1 === PHP_ZTS) {
107+
$this->markTestSkipped('symlink does not support relative paths on thread safe Windows PHP versions');
108+
}
104109
}
105110

106111
protected function markAsSkippedIfChmodIsMissing()

0 commit comments

Comments
 (0)