Skip to content

Commit 917b07a

Browse files
Merge branch '2.8' into 3.4
* 2.8: [HttpKernel] fix PHP 5.4 compat Fix surrogate not using original request [Finder] Update RealIteratorTestCase [Routing] remove unneeded dev dep on doctrine/common [Validator] Remove BOM in some xlf files
2 parents c4d972a + 0f2b752 commit 917b07a

File tree

12 files changed

+67
-17
lines changed

12 files changed

+67
-17
lines changed

src/Symfony/Component/Finder/Tests/Iterator/RealIteratorTestCase.php

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,20 @@ public static function setUpBeforeClass()
6060

6161
public static function tearDownAfterClass()
6262
{
63-
foreach (array_reverse(self::$files) as $file) {
64-
if (DIRECTORY_SEPARATOR === $file[strlen($file) - 1]) {
65-
@rmdir($file);
63+
$paths = new \RecursiveIteratorIterator(
64+
new \RecursiveDirectoryIterator(self::$tmpDir, \RecursiveDirectoryIterator::SKIP_DOTS),
65+
\RecursiveIteratorIterator::CHILD_FIRST
66+
);
67+
68+
foreach ($paths as $path) {
69+
if ($path->isDir()) {
70+
if ($path->isLink()) {
71+
@unlink($path);
72+
} else {
73+
@rmdir($path);
74+
}
6675
} else {
67-
@unlink($file);
76+
@unlink($path);
6877
}
6978
}
7079
}

src/Symfony/Component/Form/Resources/translations/validators.hy.xlf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?xml version="1.0"?>
1+
<?xml version="1.0"?>
22
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
33
<file source-language="en" datatype="plaintext" original="file.ext">
44
<body>
@@ -16,4 +16,4 @@
1616
</trans-unit>
1717
</body>
1818
</file>
19-
</xliff>
19+
</xliff>

src/Symfony/Component/Form/Resources/translations/validators.lt.xlf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?xml version="1.0"?>
1+
<?xml version="1.0"?>
22
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
33
<file source-language="en" datatype="plaintext" original="file.ext">
44
<body>
@@ -16,4 +16,4 @@
1616
</trans-unit>
1717
</body>
1818
</file>
19-
</xliff>
19+
</xliff>

src/Symfony/Component/Form/Resources/translations/validators.mn.xlf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?xml version="1.0"?>
1+
<?xml version="1.0"?>
22
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
33
<file source-language="en" datatype="plaintext" original="file.ext">
44
<body>

src/Symfony/Component/Form/Resources/translations/validators.ru.xlf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?xml version="1.0"?>
1+
<?xml version="1.0"?>
22
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
33
<file source-language="en" datatype="plaintext" original="file.ext">
44
<body>
@@ -16,4 +16,4 @@
1616
</trans-unit>
1717
</body>
1818
</file>
19-
</xliff>
19+
</xliff>

src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,11 @@ public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQ
165165
// FIXME: catch exceptions and implement a 500 error page here? -> in Varnish, there is a built-in error page mechanism
166166
if (HttpKernelInterface::MASTER_REQUEST === $type) {
167167
$this->traces = array();
168-
$this->request = $request;
168+
// Keep a clone of the original request for surrogates so they can access it.
169+
// We must clone here to get a separate instance because the application will modify the request during
170+
// the application flow (we know it always does because we do ourselves by setting REMOTE_ADDR to 127.0.0.1
171+
// and adding the X-Forwarded-For header, see HttpCache::forward()).
172+
$this->request = clone $request;
169173
if (null !== $this->surrogate) {
170174
$this->surrogateCacheStrategy = $this->surrogate->createCacheStrategy();
171175
}

src/Symfony/Component/HttpKernel/Tests/HttpCache/HttpCacheTest.php

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@
1111

1212
namespace Symfony\Component\HttpKernel\Tests\HttpCache;
1313

14+
use Symfony\Component\HttpKernel\HttpCache\Esi;
1415
use Symfony\Component\HttpKernel\HttpCache\HttpCache;
1516
use Symfony\Component\HttpFoundation\Request;
1617
use Symfony\Component\HttpFoundation\Response;
18+
use Symfony\Component\HttpKernel\HttpCache\Store;
1719
use Symfony\Component\HttpKernel\HttpKernelInterface;
1820

1921
/**
@@ -1467,6 +1469,42 @@ public function testDoesNotCacheOptionsRequest()
14671469
$this->assertHttpKernelIsNotCalled();
14681470
$this->assertSame('get', $this->response->getContent());
14691471
}
1472+
1473+
public function testUsesOriginalRequestForSurrogate()
1474+
{
1475+
$kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock();
1476+
$store = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpCache\StoreInterface')->getMock();
1477+
1478+
$kernel
1479+
->expects($this->exactly(2))
1480+
->method('handle')
1481+
->willReturnCallback(function (Request $request) {
1482+
$this->assertSame('127.0.0.1', $request->server->get('REMOTE_ADDR'));
1483+
1484+
return new Response();
1485+
});
1486+
1487+
$cache = new HttpCache($kernel,
1488+
$store,
1489+
new Esi()
1490+
);
1491+
1492+
$request = Request::create('/');
1493+
$request->server->set('REMOTE_ADDR', '10.0.0.1');
1494+
1495+
// Main request
1496+
$cache->handle($request, HttpKernelInterface::MASTER_REQUEST);
1497+
1498+
// Main request was now modified by HttpCache
1499+
// The surrogate will ask for the request using $this->cache->getRequest()
1500+
// which MUST return the original request so the surrogate
1501+
// can actually behave like a reverse proxy like e.g. Varnish would.
1502+
$this->assertSame('10.0.0.1', $cache->getRequest()->getClientIp());
1503+
$this->assertSame('10.0.0.1', $cache->getRequest()->server->get('REMOTE_ADDR'));
1504+
1505+
// Surrogate request
1506+
$cache->handle($request, HttpKernelInterface::SUB_REQUEST);
1507+
}
14701508
}
14711509

14721510
class TestKernel implements HttpKernelInterface

src/Symfony/Component/Routing/composer.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
"symfony/expression-language": "~2.8|~3.0|~4.0",
2626
"symfony/dependency-injection": "~3.3|~4.0",
2727
"doctrine/annotations": "~1.0",
28-
"doctrine/common": "~2.2",
2928
"psr/log": "~1.0"
3029
},
3130
"conflict": {

src/Symfony/Component/Validator/Resources/translations/validators.lt.xlf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?xml version="1.0"?>
1+
<?xml version="1.0"?>
22
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
33
<file source-language="en" datatype="plaintext" original="file.ext">
44
<body>

src/Symfony/Component/Validator/Resources/translations/validators.mn.xlf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?xml version="1.0"?>
1+
<?xml version="1.0"?>
22
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
33
<file source-language="en" datatype="plaintext" original="file.ext">
44
<body>

0 commit comments

Comments
 (0)