From e36099503fa9e3fb31506e0e2c618b057621f75a Mon Sep 17 00:00:00 2001 From: Sergey Rabochiy Date: Tue, 15 May 2018 18:05:47 +0700 Subject: [PATCH 01/22] [FrameworkBundle] Change priority of AddConsoleCommandPass to TYPE_BEFORE_REMOVING --- .../FrameworkBundle/FrameworkBundle.php | 2 +- .../AddConsoleCommandPassTest.php | 83 ++++++++++++++++++- 2 files changed, 80 insertions(+), 5 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/FrameworkBundle.php b/src/Symfony/Bundle/FrameworkBundle/FrameworkBundle.php index 17c12686da..6a05b436df 100644 --- a/src/Symfony/Bundle/FrameworkBundle/FrameworkBundle.php +++ b/src/Symfony/Bundle/FrameworkBundle/FrameworkBundle.php @@ -107,7 +107,7 @@ class FrameworkBundle extends Bundle $this->addCompilerPassIfExists($container, AddConstraintValidatorsPass::class, PassConfig::TYPE_BEFORE_REMOVING); $container->addCompilerPass(new AddAnnotationsCachedReaderPass(), PassConfig::TYPE_AFTER_REMOVING, -255); $this->addCompilerPassIfExists($container, AddValidatorInitializersPass::class); - $this->addCompilerPassIfExists($container, AddConsoleCommandPass::class); + $this->addCompilerPassIfExists($container, AddConsoleCommandPass::class, PassConfig::TYPE_BEFORE_REMOVING); if (class_exists(TranslatorPass::class)) { // Arguments to be removed in 4.0, relying on the default values $container->addCompilerPass(new TranslatorPass('translator.default', 'translation.loader')); diff --git a/src/Symfony/Component/Console/Tests/DependencyInjection/AddConsoleCommandPassTest.php b/src/Symfony/Component/Console/Tests/DependencyInjection/AddConsoleCommandPassTest.php index 34f6486108..67fbb98643 100644 --- a/src/Symfony/Component/Console/Tests/DependencyInjection/AddConsoleCommandPassTest.php +++ b/src/Symfony/Component/Console/Tests/DependencyInjection/AddConsoleCommandPassTest.php @@ -12,10 +12,12 @@ namespace Symfony\Component\Console\Tests\DependencyInjection; use PHPUnit\Framework\TestCase; +use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\CommandLoader\ContainerCommandLoader; use Symfony\Component\Console\DependencyInjection\AddConsoleCommandPass; -use Symfony\Component\Console\Command\Command; use Symfony\Component\DependencyInjection\Argument\ServiceClosureArgument; +use Symfony\Component\DependencyInjection\ChildDefinition; +use Symfony\Component\DependencyInjection\Compiler\PassConfig; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\TypedReference; @@ -28,7 +30,7 @@ class AddConsoleCommandPassTest extends TestCase public function testProcess($public) { $container = new ContainerBuilder(); - $container->addCompilerPass(new AddConsoleCommandPass()); + $container->addCompilerPass(new AddConsoleCommandPass(), PassConfig::TYPE_BEFORE_REMOVING); $container->setParameter('my-command.class', 'Symfony\Component\Console\Tests\DependencyInjection\MyCommand'); $definition = new Definition('%my-command.class%'); @@ -127,7 +129,7 @@ class AddConsoleCommandPassTest extends TestCase { $container = new ContainerBuilder(); $container->setResourceTracking(false); - $container->addCompilerPass(new AddConsoleCommandPass()); + $container->addCompilerPass(new AddConsoleCommandPass(), PassConfig::TYPE_BEFORE_REMOVING); $definition = new Definition('Symfony\Component\Console\Tests\DependencyInjection\MyCommand'); $definition->addTag('console.command'); @@ -145,7 +147,7 @@ class AddConsoleCommandPassTest extends TestCase { $container = new ContainerBuilder(); $container->setResourceTracking(false); - $container->addCompilerPass(new AddConsoleCommandPass()); + $container->addCompilerPass(new AddConsoleCommandPass(), PassConfig::TYPE_BEFORE_REMOVING); $definition = new Definition('SplObjectStorage'); $definition->addTag('console.command'); @@ -175,6 +177,79 @@ class AddConsoleCommandPassTest extends TestCase $this->assertTrue($container->hasAlias($alias1)); $this->assertTrue($container->hasAlias($alias2)); } + + public function testProcessOnChildDefinitionWithClass() + { + $container = new ContainerBuilder(); + $container->addCompilerPass(new AddConsoleCommandPass(), PassConfig::TYPE_BEFORE_REMOVING); + $className = 'Symfony\Component\Console\Tests\DependencyInjection\MyCommand'; + + $parentId = 'my-parent-command'; + $childId = 'my-child-command'; + + $parentDefinition = new Definition(/* no class */); + $parentDefinition->setAbstract(true)->setPublic(false); + + $childDefinition = new ChildDefinition($parentId); + $childDefinition->addTag('console.command')->setPublic(true); + $childDefinition->setClass($className); + + $container->setDefinition($parentId, $parentDefinition); + $container->setDefinition($childId, $childDefinition); + + $container->compile(); + $command = $container->get($childId); + + $this->assertInstanceOf($className, $command); + } + + public function testProcessOnChildDefinitionWithParentClass() + { + $container = new ContainerBuilder(); + $container->addCompilerPass(new AddConsoleCommandPass(), PassConfig::TYPE_BEFORE_REMOVING); + $className = 'Symfony\Component\Console\Tests\DependencyInjection\MyCommand'; + + $parentId = 'my-parent-command'; + $childId = 'my-child-command'; + + $parentDefinition = new Definition($className); + $parentDefinition->setAbstract(true)->setPublic(false); + + $childDefinition = new ChildDefinition($parentId); + $childDefinition->addTag('console.command')->setPublic(true); + + $container->setDefinition($parentId, $parentDefinition); + $container->setDefinition($childId, $childDefinition); + + $container->compile(); + $command = $container->get($childId); + + $this->assertInstanceOf($className, $command); + } + + /** + * @expectedException \RuntimeException + * @expectedExceptionMessage The definition for "my-child-command" has no class. + */ + public function testProcessOnChildDefinitionWithoutClass() + { + $container = new ContainerBuilder(); + $container->addCompilerPass(new AddConsoleCommandPass(), PassConfig::TYPE_BEFORE_REMOVING); + + $parentId = 'my-parent-command'; + $childId = 'my-child-command'; + + $parentDefinition = new Definition(); + $parentDefinition->setAbstract(true)->setPublic(false); + + $childDefinition = new ChildDefinition($parentId); + $childDefinition->addTag('console.command')->setPublic(true); + + $container->setDefinition($parentId, $parentDefinition); + $container->setDefinition($childId, $childDefinition); + + $container->compile(); + } } class MyCommand extends Command From ca314889e7fb7a8b5c1f58ca489b9a22b7e71293 Mon Sep 17 00:00:00 2001 From: Maxime Steinhausser Date: Sat, 26 May 2018 11:34:32 +0200 Subject: [PATCH 02/22] [Serializer] Fix serializer tries to denormalize null values on nullable properties --- .../Normalizer/AbstractNormalizer.php | 6 ++++ .../NullableConstructorArgumentDummy.php | 32 +++++++++++++++++++ .../Normalizer/AbstractNormalizerTest.php | 12 +++++++ 3 files changed, 50 insertions(+) create mode 100644 src/Symfony/Component/Serializer/Tests/Fixtures/NullableConstructorArgumentDummy.php diff --git a/src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php b/src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php index 74a133214f..cad6205dfb 100644 --- a/src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php +++ b/src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php @@ -349,6 +349,12 @@ abstract class AbstractNormalizer extends SerializerAwareNormalizer implements N } } elseif ($allowed && !$ignored && (isset($data[$key]) || array_key_exists($key, $data))) { $parameterData = $data[$key]; + if (null === $parameterData && $constructorParameter->allowsNull()) { + $params[] = null; + // Don't run set for a parameter passed to the constructor + unset($data[$key]); + continue; + } try { if (null !== $constructorParameter->getClass()) { if (!$this->serializer instanceof DenormalizerInterface) { diff --git a/src/Symfony/Component/Serializer/Tests/Fixtures/NullableConstructorArgumentDummy.php b/src/Symfony/Component/Serializer/Tests/Fixtures/NullableConstructorArgumentDummy.php new file mode 100644 index 0000000000..616fab4ae8 --- /dev/null +++ b/src/Symfony/Component/Serializer/Tests/Fixtures/NullableConstructorArgumentDummy.php @@ -0,0 +1,32 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Serializer\Tests\Fixtures; + +class NullableConstructorArgumentDummy +{ + private $foo; + + public function __construct(?\stdClass $foo) + { + $this->foo = $foo; + } + + public function setFoo($foo) + { + $this->foo = 'this setter should not be called when using the constructor argument'; + } + + public function getFoo() + { + return $this->foo; + } +} diff --git a/src/Symfony/Component/Serializer/Tests/Normalizer/AbstractNormalizerTest.php b/src/Symfony/Component/Serializer/Tests/Normalizer/AbstractNormalizerTest.php index e07fb56bf5..28edc05872 100644 --- a/src/Symfony/Component/Serializer/Tests/Normalizer/AbstractNormalizerTest.php +++ b/src/Symfony/Component/Serializer/Tests/Normalizer/AbstractNormalizerTest.php @@ -9,6 +9,7 @@ use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactoryInterface; use Symfony\Component\Serializer\Normalizer\AbstractNormalizer; use Symfony\Component\Serializer\Normalizer\ObjectNormalizer; use Symfony\Component\Serializer\Tests\Fixtures\AbstractNormalizerDummy; +use Symfony\Component\Serializer\Tests\Fixtures\NullableConstructorArgumentDummy; use Symfony\Component\Serializer\Tests\Fixtures\ProxyDummy; use Symfony\Component\Serializer\Tests\Fixtures\StaticConstructorDummy; use Symfony\Component\Serializer\Tests\Fixtures\StaticConstructorNormalizer; @@ -116,4 +117,15 @@ class AbstractNormalizerTest extends TestCase $this->assertEquals('baz', $dummy->quz); $this->assertNull($dummy->foo); } + + /** + * @requires PHP 7.1 + */ + public function testObjectWithNullableConstructorArgument() + { + $normalizer = new ObjectNormalizer(); + $dummy = $normalizer->denormalize(array('foo' => null), NullableConstructorArgumentDummy::class); + + $this->assertNull($dummy->getFoo()); + } } From a89a1019a72effa02f7c79ceeaf7ec90a4966236 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sat, 26 May 2018 17:53:18 +0200 Subject: [PATCH 03/22] updated CHANGELOG for 4.1.0-BETA3 --- CHANGELOG-4.1.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/CHANGELOG-4.1.md b/CHANGELOG-4.1.md index 5437c76fd6..a042563276 100644 --- a/CHANGELOG-4.1.md +++ b/CHANGELOG-4.1.md @@ -7,6 +7,30 @@ in 4.1 minor versions. To get the diff for a specific change, go to https://github.com/symfony/symfony/commit/XXX where XXX is the change hash To get the diff between two versions, go to https://github.com/symfony/symfony/compare/v4.1.0...v4.1.1 +* 4.1.0-BETA3 (2018-05-26) + + * bug #27388 [Routing] Account for greediness when merging route patterns (nicolas-grekas) + * bug #27344 [HttpKernel] reset kernel start time on reboot (kiler129) + * bug #27365 [Serializer] Check the value of enable_max_depth if defined (dunglas) + * bug #27358 [PhpUnitBridge] silence some stderr outputs (ostrolucky) + * bug #27366 [DI] never inline lazy services (nicolas-grekas) + * bug #27352 Remove reference to the test container after kernel shutdown (stof) + * bug #27350 [HttpKernel] fix deprecation in AbstractTestSessionListener (alekitto) + * bug #27367 [FrameworkBundle] cleanup generated test container (nicolas-grekas) + * bug #27379 [FrameworkBundle] Fix using test.service_container when Client is rebooted (nicolas-grekas) + * bug #27364 [DI] Fix bad exception on uninitialized references to non-shared services (nicolas-grekas) + * bug #27359 [HttpFoundation] Fix perf issue during MimeTypeGuesser intialization (nicolas-grekas) + * security #cve-2018-11408 [SecurityBundle] Fail if security.http_utils cannot be configured + * security #cve-2018-11406 clear CSRF tokens when the user is logged out + * security #cve-2018-11385 migrating session for UsernamePasswordJsonAuthenticationListener + * security #cve-2018-11385 migrating session for UsernamePasswordJsonAuthenticationListener + * security #cve-2018-11385 Adding session authentication strategy to Guard to avoid session fixation + * security #cve-2018-11385 Adding session strategy to ALL listeners to avoid *any* possible fixation + * security #cve-2018-11386 [HttpFoundation] Break infinite loop in PdoSessionHandler when MySQL is in loose mode + * bug #27341 [WebProfilerBundle] Fixed validator/dump trace CSS (yceruto) + * bug #27337 [FrameworkBundle] fix typo in CacheClearCommand (emilielorenzo) + * bug #27292 [Serializer] Fix and improve constraintViolationListNormalizer's RFC7807 compliance (dunglas) + * 4.1.0-BETA2 (2018-05-21) * bug #27312 Supress deprecation notices thrown when getting private servies from container in tests (arderyp) From ce538ca5590b65d0a98f89859fdf968902c5f98a Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sat, 26 May 2018 17:53:24 +0200 Subject: [PATCH 04/22] updated VERSION for 4.1.0-BETA3 --- src/Symfony/Component/HttpKernel/Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/HttpKernel/Kernel.php b/src/Symfony/Component/HttpKernel/Kernel.php index 051ad7b5a0..4fbabf8d9b 100644 --- a/src/Symfony/Component/HttpKernel/Kernel.php +++ b/src/Symfony/Component/HttpKernel/Kernel.php @@ -63,12 +63,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private $requestStackSize = 0; private $resetServices = false; - const VERSION = '4.1.0-DEV'; + const VERSION = '4.1.0-BETA3'; const VERSION_ID = 40100; const MAJOR_VERSION = 4; const MINOR_VERSION = 1; const RELEASE_VERSION = 0; - const EXTRA_VERSION = 'DEV'; + const EXTRA_VERSION = 'BETA3'; const END_OF_MAINTENANCE = '01/2019'; const END_OF_LIFE = '07/2019'; From 62adf931091a8ab8c75462a09457a8c4162b1a41 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sat, 26 May 2018 17:55:46 +0200 Subject: [PATCH 05/22] bumped Symfony version to 4.1.0 --- src/Symfony/Component/HttpKernel/Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/HttpKernel/Kernel.php b/src/Symfony/Component/HttpKernel/Kernel.php index 4fbabf8d9b..051ad7b5a0 100644 --- a/src/Symfony/Component/HttpKernel/Kernel.php +++ b/src/Symfony/Component/HttpKernel/Kernel.php @@ -63,12 +63,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private $requestStackSize = 0; private $resetServices = false; - const VERSION = '4.1.0-BETA3'; + const VERSION = '4.1.0-DEV'; const VERSION_ID = 40100; const MAJOR_VERSION = 4; const MINOR_VERSION = 1; const RELEASE_VERSION = 0; - const EXTRA_VERSION = 'BETA3'; + const EXTRA_VERSION = 'DEV'; const END_OF_MAINTENANCE = '01/2019'; const END_OF_LIFE = '07/2019'; From e3412e6a6732093920b08e8b2b612d8c21ea979c Mon Sep 17 00:00:00 2001 From: Ryan Weaver Date: Thu, 17 May 2018 09:59:56 -0400 Subject: [PATCH 06/22] Triggering RememberMe's loginFail() when token cannot be created --- .../Http/Firewall/RememberMeListener.php | 20 +++++++++- .../Tests/Firewall/RememberMeListenerTest.php | 37 +++++++++++++++++++ 2 files changed, 56 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/Security/Http/Firewall/RememberMeListener.php b/src/Symfony/Component/Security/Http/Firewall/RememberMeListener.php index fe670f3de1..d139e7a5fa 100644 --- a/src/Symfony/Component/Security/Http/Firewall/RememberMeListener.php +++ b/src/Symfony/Component/Security/Http/Firewall/RememberMeListener.php @@ -68,7 +68,25 @@ class RememberMeListener implements ListenerInterface } $request = $event->getRequest(); - if (null === $token = $this->rememberMeServices->autoLogin($request)) { + try { + if (null === $token = $this->rememberMeServices->autoLogin($request)) { + return; + } + } catch (AuthenticationException $e) { + if (null !== $this->logger) { + $this->logger->warning( + 'The token storage was not populated with remember-me token as the' + .' RememberMeServices was not able to create a token from the remember' + .' me information.', array('exception' => $e) + ); + } + + $this->rememberMeServices->loginFail($request); + + if (!$this->catchExceptions) { + throw $e; + } + return; } diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/RememberMeListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/RememberMeListenerTest.php index 2249dcbd20..6fb7e3c592 100644 --- a/src/Symfony/Component/Security/Http/Tests/Firewall/RememberMeListenerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Firewall/RememberMeListenerTest.php @@ -143,6 +143,43 @@ class RememberMeListenerTest extends TestCase $listener->handle($event); } + public function testOnCoreSecurityAuthenticationExceptionDuringAutoLoginTriggersLoginFail() + { + list($listener, $tokenStorage, $service, $manager) = $this->getListener(); + + $tokenStorage + ->expects($this->once()) + ->method('getToken') + ->will($this->returnValue(null)) + ; + + $exception = new AuthenticationException('Authentication failed.'); + $service + ->expects($this->once()) + ->method('autoLogin') + ->will($this->throwException($exception)) + ; + + $service + ->expects($this->once()) + ->method('loginFail') + ; + + $manager + ->expects($this->never()) + ->method('authenticate') + ; + + $event = $this->getGetResponseEvent(); + $event + ->expects($this->once()) + ->method('getRequest') + ->will($this->returnValue(new Request())) + ; + + $listener->handle($event); + } + public function testOnCoreSecurity() { list($listener, $tokenStorage, $service, $manager) = $this->getListener(); From 9372e7a8136ab677b74c7a31a7a13b8ee1db10c5 Mon Sep 17 00:00:00 2001 From: Alexey Kopytko Date: Fri, 18 May 2018 18:18:34 +0900 Subject: [PATCH 07/22] [Process] Consider \"executable\" suffixes first on Windows --- .../Component/Process/ExecutableFinder.php | 2 +- .../Process/Tests/ExecutableFinderTest.php | 30 +++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/Process/ExecutableFinder.php b/src/Symfony/Component/Process/ExecutableFinder.php index 1ec6526d45..defa66de6b 100644 --- a/src/Symfony/Component/Process/ExecutableFinder.php +++ b/src/Symfony/Component/Process/ExecutableFinder.php @@ -73,7 +73,7 @@ class ExecutableFinder $suffixes = array(''); if ('\\' === DIRECTORY_SEPARATOR) { $pathExt = getenv('PATHEXT'); - $suffixes = array_merge($suffixes, $pathExt ? explode(PATH_SEPARATOR, $pathExt) : $this->suffixes); + $suffixes = array_merge($pathExt ? explode(PATH_SEPARATOR, $pathExt) : $this->suffixes, $suffixes); } foreach ($suffixes as $suffix) { foreach ($dirs as $dir) { diff --git a/src/Symfony/Component/Process/Tests/ExecutableFinderTest.php b/src/Symfony/Component/Process/Tests/ExecutableFinderTest.php index 3aaeb0fb88..669e1b3eb6 100644 --- a/src/Symfony/Component/Process/Tests/ExecutableFinderTest.php +++ b/src/Symfony/Component/Process/Tests/ExecutableFinderTest.php @@ -129,6 +129,36 @@ class ExecutableFinderTest extends TestCase $this->assertSamePath(PHP_BINARY, $result); } + /** + * @requires PHP 5.4 + */ + public function testFindBatchExecutableOnWindows() + { + if (ini_get('open_basedir')) { + $this->markTestSkipped('Cannot test when open_basedir is set'); + } + if ('\\' !== DIRECTORY_SEPARATOR) { + $this->markTestSkipped('Can be only tested on windows'); + } + + $target = tempnam(sys_get_temp_dir(), 'example-windows-executable'); + + touch($target); + touch($target.'.BAT'); + + $this->assertFalse(is_executable($target)); + + $this->setPath(sys_get_temp_dir()); + + $finder = new ExecutableFinder(); + $result = $finder->find(basename($target), false); + + unlink($target); + unlink($target.'.BAT'); + + $this->assertSamePath($target.'.BAT', $result); + } + private function assertSamePath($expected, $tested) { if ('\\' === DIRECTORY_SEPARATOR) { From 18f55feef85c51368549833a89bcb223cd433a37 Mon Sep 17 00:00:00 2001 From: Kamil Madejski Date: Wed, 18 Apr 2018 13:57:06 +0200 Subject: [PATCH 08/22] [HttpKernel] Set first trusted proxy as REMOTE_ADDR in InlineFragmentRenderer. --- .../HttpKernel/Fragment/InlineFragmentRenderer.php | 4 +++- .../Tests/Fragment/InlineFragmentRendererTest.php | 6 ++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Component/HttpKernel/Fragment/InlineFragmentRenderer.php b/src/Symfony/Component/HttpKernel/Fragment/InlineFragmentRenderer.php index 17ed967fb5..76c8e95d79 100644 --- a/src/Symfony/Component/HttpKernel/Fragment/InlineFragmentRenderer.php +++ b/src/Symfony/Component/HttpKernel/Fragment/InlineFragmentRenderer.php @@ -122,7 +122,9 @@ class InlineFragmentRenderer extends RoutableFragmentRenderer // Do nothing } - $server['REMOTE_ADDR'] = '127.0.0.1'; + $trustedProxies = Request::getTrustedProxies(); + $server['REMOTE_ADDR'] = $trustedProxies ? reset($trustedProxies) : '127.0.0.1'; + unset($server['HTTP_IF_MODIFIED_SINCE']); unset($server['HTTP_IF_NONE_MATCH']); diff --git a/src/Symfony/Component/HttpKernel/Tests/Fragment/InlineFragmentRendererTest.php b/src/Symfony/Component/HttpKernel/Tests/Fragment/InlineFragmentRendererTest.php index 4c1d6a00c4..6ed3c86537 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Fragment/InlineFragmentRendererTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/Fragment/InlineFragmentRendererTest.php @@ -56,6 +56,7 @@ class InlineFragmentRendererTest extends TestCase $subRequest->attributes->replace(array('object' => $object, '_format' => 'html', '_controller' => 'main_controller', '_locale' => 'en')); $subRequest->headers->set('x-forwarded-for', array('127.0.0.1')); $subRequest->server->set('HTTP_X_FORWARDED_FOR', '127.0.0.1'); + $subRequest->server->set('REMOTE_ADDR', '1.1.1.1'); $strategy = new InlineFragmentRenderer($this->getKernelExpectingRequest($subRequest)); @@ -84,7 +85,7 @@ class InlineFragmentRendererTest extends TestCase { Request::setTrustedHeaderName(Request::HEADER_CLIENT_IP, ''); - $strategy = new InlineFragmentRenderer($this->getKernelExpectingRequest(Request::create('/'))); + $strategy = new InlineFragmentRenderer($this->getKernelExpectingRequest(Request::create('/', 'GET', array(), array(), array(), array('REMOTE_ADDR' => '1.1.1.1')))); $this->assertSame('foo', $strategy->render('/', Request::create('/'))->getContent()); } @@ -168,6 +169,7 @@ class InlineFragmentRendererTest extends TestCase { $expectedSubRequest = Request::create('/'); $expectedSubRequest->headers->set('Surrogate-Capability', 'abc="ESI/1.0"'); + $expectedSubRequest->server->set('REMOTE_ADDR', '1.1.1.1'); if (Request::getTrustedHeaderName(Request::HEADER_CLIENT_IP)) { $expectedSubRequest->headers->set('x-forwarded-for', array('127.0.0.1')); @@ -193,7 +195,7 @@ class InlineFragmentRendererTest extends TestCase public function testHeadersPossiblyResultingIn304AreNotAssignedToSubrequest() { - $expectedSubRequest = Request::create('/'); + $expectedSubRequest = Request::create('/', 'GET', array(), array(), array(), array('REMOTE_ADDR' => '1.1.1.1')); if (Request::getTrustedHeaderName(Request::HEADER_CLIENT_IP)) { $expectedSubRequest->headers->set('x-forwarded-for', array('127.0.0.1')); $expectedSubRequest->server->set('HTTP_X_FORWARDED_FOR', '127.0.0.1'); From 744362ad024e5eb45094bc600f500dcc830efb05 Mon Sep 17 00:00:00 2001 From: Martin Hujer Date: Sun, 27 May 2018 18:59:28 +0200 Subject: [PATCH 09/22] update UPGRADE-4.1 for feature #26332 Form field help option --- UPGRADE-4.1.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/UPGRADE-4.1.md b/UPGRADE-4.1.md index 64921efd28..d6202c682f 100644 --- a/UPGRADE-4.1.md +++ b/UPGRADE-4.1.md @@ -64,6 +64,9 @@ Form } ``` + * Added `help` option to the form field. If you have custom Form extension for it, you should remove it. + Also remove it from the custom form theme. + FrameworkBundle --------------- From 92e3023195e4afeed0568a4e94adf2dc2453aa1a Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Mon, 28 May 2018 17:16:05 +0200 Subject: [PATCH 10/22] [HttpKernel] fix registering IDE links --- src/Symfony/Bundle/FrameworkBundle/FrameworkBundle.php | 3 --- src/Symfony/Bundle/FrameworkBundle/Resources/config/web.xml | 1 + .../WebProfilerBundle/Controller/ExceptionController.php | 1 + .../HttpKernel/EventListener/ExceptionListener.php | 6 ++++-- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/FrameworkBundle.php b/src/Symfony/Bundle/FrameworkBundle/FrameworkBundle.php index 17c12686da..2a62d391a7 100644 --- a/src/Symfony/Bundle/FrameworkBundle/FrameworkBundle.php +++ b/src/Symfony/Bundle/FrameworkBundle/FrameworkBundle.php @@ -61,9 +61,6 @@ class FrameworkBundle extends Bundle { public function boot() { - if (!ini_get('xdebug.file_link_format') && !get_cfg_var('xdebug.file_link_format')) { - ini_set('xdebug.file_link_format', $this->container->getParameter('debug.file_link_format')); - } ErrorHandler::register(null, false)->throwAt($this->container->getParameter('debug.error_handler.throw_at'), true); if ($this->container->hasParameter('kernel.trusted_proxies')) { diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/web.xml b/src/Symfony/Bundle/FrameworkBundle/Resources/config/web.xml index 565aef68fd..f6dd2bb9df 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/web.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/web.xml @@ -74,6 +74,7 @@ %kernel.debug% %kernel.charset% + %debug.file_link_format% diff --git a/src/Symfony/Bundle/WebProfilerBundle/Controller/ExceptionController.php b/src/Symfony/Bundle/WebProfilerBundle/Controller/ExceptionController.php index f008b0b528..2137477a5c 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Controller/ExceptionController.php +++ b/src/Symfony/Bundle/WebProfilerBundle/Controller/ExceptionController.php @@ -30,6 +30,7 @@ class ExceptionController protected $twig; protected $debug; protected $profiler; + private $fileLinkFormat; public function __construct(Profiler $profiler = null, Environment $twig, $debug, FileLinkFormatter $fileLinkFormat = null) { diff --git a/src/Symfony/Component/HttpKernel/EventListener/ExceptionListener.php b/src/Symfony/Component/HttpKernel/EventListener/ExceptionListener.php index 3dfa4cd8ea..4d8ad1e7e5 100644 --- a/src/Symfony/Component/HttpKernel/EventListener/ExceptionListener.php +++ b/src/Symfony/Component/HttpKernel/EventListener/ExceptionListener.php @@ -36,13 +36,15 @@ class ExceptionListener implements EventSubscriberInterface protected $logger; protected $debug; private $charset; + private $fileLinkFormat; - public function __construct($controller, LoggerInterface $logger = null, $debug = false, $charset = null) + public function __construct($controller, LoggerInterface $logger = null, $debug = false, $charset = null, $fileLinkFormat = null) { $this->controller = $controller; $this->logger = $logger; $this->debug = $debug; $this->charset = $charset; + $this->fileLinkFormat = $fileLinkFormat; } public function onKernelException(GetResponseForExceptionEvent $event) @@ -123,7 +125,7 @@ class ExceptionListener implements EventSubscriberInterface $attributes = array( 'exception' => $exception = FlattenException::create($exception), '_controller' => $this->controller ?: function () use ($exception) { - $handler = new ExceptionHandler($this->debug, $this->charset); + $handler = new ExceptionHandler($this->debug, $this->charset, $this->fileLinkFormat); return new Response($handler->getHtml($exception), $exception->getStatusCode(), $exception->getHeaders()); }, From 479aa9074b40ef9cc01c5369681c30a81b832ceb Mon Sep 17 00:00:00 2001 From: Davide Borsatto Date: Tue, 29 May 2018 10:57:40 +0200 Subject: [PATCH 11/22] Change PHPDoc in ResponseHeaderBag::getCookies() to help IDEs --- src/Symfony/Component/HttpFoundation/ResponseHeaderBag.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/HttpFoundation/ResponseHeaderBag.php b/src/Symfony/Component/HttpFoundation/ResponseHeaderBag.php index a042328ca5..c299c36928 100644 --- a/src/Symfony/Component/HttpFoundation/ResponseHeaderBag.php +++ b/src/Symfony/Component/HttpFoundation/ResponseHeaderBag.php @@ -160,7 +160,7 @@ class ResponseHeaderBag extends HeaderBag * * @param string $format * - * @return array + * @return Cookie[] * * @throws \InvalidArgumentException When the $format is invalid */ From 09c660d45442c09bdcbe790652783f861bd3922f Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 30 May 2018 06:18:11 +0200 Subject: [PATCH 12/22] removed unneeded comments in tests --- .../Tests/OptionsResolver2Dot6Test.php | 64 ------------------- 1 file changed, 64 deletions(-) diff --git a/src/Symfony/Component/OptionsResolver/Tests/OptionsResolver2Dot6Test.php b/src/Symfony/Component/OptionsResolver/Tests/OptionsResolver2Dot6Test.php index ffa2872243..aeaf019969 100644 --- a/src/Symfony/Component/OptionsResolver/Tests/OptionsResolver2Dot6Test.php +++ b/src/Symfony/Component/OptionsResolver/Tests/OptionsResolver2Dot6Test.php @@ -29,10 +29,6 @@ class OptionsResolver2Dot6Test extends TestCase $this->resolver = new OptionsResolver(); } - //////////////////////////////////////////////////////////////////////////// - // resolve() - //////////////////////////////////////////////////////////////////////////// - /** * @expectedException \Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException * @expectedExceptionMessage The option "foo" does not exist. Defined options are: "a", "z". @@ -69,10 +65,6 @@ class OptionsResolver2Dot6Test extends TestCase $this->resolver->resolve(); } - //////////////////////////////////////////////////////////////////////////// - // setDefault()/hasDefault() - //////////////////////////////////////////////////////////////////////////// - public function testSetDefaultReturnsThis() { $this->assertSame($this->resolver, $this->resolver->setDefault('foo', 'bar')); @@ -115,10 +107,6 @@ class OptionsResolver2Dot6Test extends TestCase $this->assertTrue($this->resolver->hasDefault('foo')); } - //////////////////////////////////////////////////////////////////////////// - // lazy setDefault() - //////////////////////////////////////////////////////////////////////////// - public function testSetLazyReturnsThis() { $this->assertSame($this->resolver, $this->resolver->setDefault('foo', function (Options $options) {})); @@ -232,10 +220,6 @@ class OptionsResolver2Dot6Test extends TestCase $this->assertSame(2, $calls); } - //////////////////////////////////////////////////////////////////////////// - // setRequired()/isRequired()/getRequiredOptions() - //////////////////////////////////////////////////////////////////////////// - public function testSetRequiredReturnsThis() { $this->assertSame($this->resolver, $this->resolver->setRequired('foo')); @@ -330,10 +314,6 @@ class OptionsResolver2Dot6Test extends TestCase $this->assertSame(array('foo', 'bar'), $this->resolver->getRequiredOptions()); } - //////////////////////////////////////////////////////////////////////////// - // isMissing()/getMissingOptions() - //////////////////////////////////////////////////////////////////////////// - public function testIsMissingIfNotSet() { $this->assertFalse($this->resolver->isMissing('foo')); @@ -373,10 +353,6 @@ class OptionsResolver2Dot6Test extends TestCase $this->assertSame(array('bar'), $this->resolver->getMissingOptions()); } - //////////////////////////////////////////////////////////////////////////// - // setDefined()/isDefined()/getDefinedOptions() - //////////////////////////////////////////////////////////////////////////// - /** * @expectedException \Symfony\Component\OptionsResolver\Exception\AccessException */ @@ -474,10 +450,6 @@ class OptionsResolver2Dot6Test extends TestCase $this->assertFalse($this->resolver->isDefined('foo')); } - //////////////////////////////////////////////////////////////////////////// - // setAllowedTypes() - //////////////////////////////////////////////////////////////////////////// - /** * @expectedException \Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException */ @@ -568,10 +540,6 @@ class OptionsResolver2Dot6Test extends TestCase $this->assertNotEmpty($this->resolver->resolve()); } - //////////////////////////////////////////////////////////////////////////// - // addAllowedTypes() - //////////////////////////////////////////////////////////////////////////// - /** * @expectedException \Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException */ @@ -654,10 +622,6 @@ class OptionsResolver2Dot6Test extends TestCase $this->assertNotEmpty($this->resolver->resolve()); } - //////////////////////////////////////////////////////////////////////////// - // setAllowedValues() - //////////////////////////////////////////////////////////////////////////// - /** * @expectedException \Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException */ @@ -809,10 +773,6 @@ class OptionsResolver2Dot6Test extends TestCase $this->assertEquals(array('foo' => 'bar'), $this->resolver->resolve()); } - //////////////////////////////////////////////////////////////////////////// - // addAllowedValues() - //////////////////////////////////////////////////////////////////////////// - /** * @expectedException \Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException */ @@ -929,10 +889,6 @@ class OptionsResolver2Dot6Test extends TestCase $this->assertEquals(array('foo' => 'bar'), $this->resolver->resolve()); } - //////////////////////////////////////////////////////////////////////////// - // setNormalizer() - //////////////////////////////////////////////////////////////////////////// - public function testSetNormalizerReturnsThis() { $this->resolver->setDefault('foo', 'bar'); @@ -1184,10 +1140,6 @@ class OptionsResolver2Dot6Test extends TestCase $this->assertEmpty($this->resolver->resolve()); } - //////////////////////////////////////////////////////////////////////////// - // setDefaults() - //////////////////////////////////////////////////////////////////////////// - public function testSetDefaultsReturnsThis() { $this->assertSame($this->resolver, $this->resolver->setDefaults(array('foo', 'bar'))); @@ -1222,10 +1174,6 @@ class OptionsResolver2Dot6Test extends TestCase $this->resolver->resolve(); } - //////////////////////////////////////////////////////////////////////////// - // remove() - //////////////////////////////////////////////////////////////////////////// - public function testRemoveReturnsThis() { $this->resolver->setDefault('foo', 'bar'); @@ -1314,10 +1262,6 @@ class OptionsResolver2Dot6Test extends TestCase $this->assertNotNull($this->resolver->remove('foo')); } - //////////////////////////////////////////////////////////////////////////// - // clear() - //////////////////////////////////////////////////////////////////////////// - public function testClearReturnsThis() { $this->assertSame($this->resolver, $this->resolver->clear()); @@ -1404,10 +1348,6 @@ class OptionsResolver2Dot6Test extends TestCase $this->assertEmpty($this->resolver->resolve()); } - //////////////////////////////////////////////////////////////////////////// - // ArrayAccess - //////////////////////////////////////////////////////////////////////////// - public function testArrayAccess() { $this->resolver->setDefault('default1', 0); @@ -1522,10 +1462,6 @@ class OptionsResolver2Dot6Test extends TestCase $this->resolver->resolve(); } - //////////////////////////////////////////////////////////////////////////// - // Countable - //////////////////////////////////////////////////////////////////////////// - public function testCount() { $this->resolver->setDefault('default', 0); From 28c8c85da1d5f93b141ab477c4f2a9761548f363 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 30 May 2018 06:26:49 +0200 Subject: [PATCH 13/22] removed unneeded comments in tests --- .../Component/OptionsResolver/Tests/OptionsResolverTest.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/Symfony/Component/OptionsResolver/Tests/OptionsResolverTest.php b/src/Symfony/Component/OptionsResolver/Tests/OptionsResolverTest.php index f50911d374..12dc77b3c6 100644 --- a/src/Symfony/Component/OptionsResolver/Tests/OptionsResolverTest.php +++ b/src/Symfony/Component/OptionsResolver/Tests/OptionsResolverTest.php @@ -634,10 +634,6 @@ class OptionsResolverTest extends TestCase $this->resolver->resolve(); } - //////////////////////////////////////////////////////////////////////////// - // addAllowedTypes() - //////////////////////////////////////////////////////////////////////////// - /** * @expectedException \Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException */ From 8c62ecfad2001fe062559fd4a2f8893c31500411 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dunglas?= Date: Wed, 30 May 2018 07:26:26 +0200 Subject: [PATCH 14/22] CODEOWNERS: some more rules --- .github/CODEOWNERS | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index db1c2a8a6f..415464c40b 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1,3 +1,9 @@ +# Console +/src/Symfony/Component/Console/Logger/ConsoleLogger.php @dunglas +# DependencyInjection +/src/Symfony/Component/DependencyInjection/Compiler/AutowirePass.php @dunglas +# HttpKernel +/src/Symfony/Component/HttpKernel/Log/Logger.php @dunglas # LDAP /src/Symfony/Component/Ldap/* @csarrazi # Lock @@ -5,6 +11,13 @@ # Messenger /src/Symfony/Bridge/Doctrine/Messenger/* @sroze /src/Symfony/Component/Messenger/* @sroze +# PropertyInfo +/src/Symfony/Component/PropertyInfo/* @dunglas +/src/Symfony/Bridge/Doctrine/PropertyInfo/* @dunglas +# Serializer +/src/Symfony/Component/Serializer/* @dunglas +# WebLink +/src/Symfony/Component/WebLink/* @dunglas # Workflow /src/Symfony/Bridge/Twig/Extension/WorkflowExtension.php @lyrixx /src/Symfony/Bridge/Twig/Tests/Extension/WorkflowExtensionTest.php @lyrixx From 2ddb89b7a3ba0dd0c5b067d6dcfa80bfd1287c86 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Wed, 30 May 2018 09:24:25 +0200 Subject: [PATCH 15/22] Revert "feature #26702 Mark ExceptionInterfaces throwable (ostrolucky)" This reverts commit 9fda6d3ee3ea7f32a00a13508f9748df01c2ecc7, reversing changes made to ca53d3e0fdfce16b0bd9e8412ef220daf77cf58d. --- src/Symfony/Component/Asset/Exception/ExceptionInterface.php | 2 +- src/Symfony/Component/Console/Exception/ExceptionInterface.php | 2 +- .../Component/CssSelector/Exception/ExceptionInterface.php | 2 +- src/Symfony/Component/Dotenv/Exception/ExceptionInterface.php | 2 +- .../Component/Filesystem/Exception/ExceptionInterface.php | 2 +- src/Symfony/Component/Form/Exception/ExceptionInterface.php | 2 +- src/Symfony/Component/Intl/Exception/ExceptionInterface.php | 2 +- src/Symfony/Component/Ldap/Exception/ExceptionInterface.php | 2 +- src/Symfony/Component/Lock/Exception/ExceptionInterface.php | 2 +- .../Component/Messenger/Exception/ExceptionInterface.php | 2 +- .../Component/OptionsResolver/Exception/ExceptionInterface.php | 2 +- src/Symfony/Component/Process/Exception/ExceptionInterface.php | 2 +- .../Component/PropertyAccess/Exception/ExceptionInterface.php | 2 +- src/Symfony/Component/Routing/Exception/ExceptionInterface.php | 2 +- .../Component/Security/Core/Exception/ExceptionInterface.php | 2 +- .../Component/Serializer/Exception/ExceptionInterface.php | 2 +- .../Component/Translation/Exception/ExceptionInterface.php | 2 +- .../Component/Validator/Exception/ExceptionInterface.php | 2 +- src/Symfony/Component/Workflow/Exception/ExceptionInterface.php | 2 +- src/Symfony/Component/Yaml/Exception/ExceptionInterface.php | 2 +- 20 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/Symfony/Component/Asset/Exception/ExceptionInterface.php b/src/Symfony/Component/Asset/Exception/ExceptionInterface.php index 777f64b321..cce1b5cced 100644 --- a/src/Symfony/Component/Asset/Exception/ExceptionInterface.php +++ b/src/Symfony/Component/Asset/Exception/ExceptionInterface.php @@ -16,6 +16,6 @@ namespace Symfony\Component\Asset\Exception; * * @author Fabien Potencier */ -interface ExceptionInterface extends \Throwable +interface ExceptionInterface { } diff --git a/src/Symfony/Component/Console/Exception/ExceptionInterface.php b/src/Symfony/Component/Console/Exception/ExceptionInterface.php index 1624e13d0b..491cc4c645 100644 --- a/src/Symfony/Component/Console/Exception/ExceptionInterface.php +++ b/src/Symfony/Component/Console/Exception/ExceptionInterface.php @@ -16,6 +16,6 @@ namespace Symfony\Component\Console\Exception; * * @author Jérôme Tamarelle */ -interface ExceptionInterface extends \Throwable +interface ExceptionInterface { } diff --git a/src/Symfony/Component/CssSelector/Exception/ExceptionInterface.php b/src/Symfony/Component/CssSelector/Exception/ExceptionInterface.php index 9e259006b0..e4c5ae1b6b 100644 --- a/src/Symfony/Component/CssSelector/Exception/ExceptionInterface.php +++ b/src/Symfony/Component/CssSelector/Exception/ExceptionInterface.php @@ -19,6 +19,6 @@ namespace Symfony\Component\CssSelector\Exception; * * @author Jean-François Simon */ -interface ExceptionInterface extends \Throwable +interface ExceptionInterface { } diff --git a/src/Symfony/Component/Dotenv/Exception/ExceptionInterface.php b/src/Symfony/Component/Dotenv/Exception/ExceptionInterface.php index 140a93f966..90509f7db5 100644 --- a/src/Symfony/Component/Dotenv/Exception/ExceptionInterface.php +++ b/src/Symfony/Component/Dotenv/Exception/ExceptionInterface.php @@ -16,6 +16,6 @@ namespace Symfony\Component\Dotenv\Exception; * * @author Fabien Potencier */ -interface ExceptionInterface extends \Throwable +interface ExceptionInterface { } diff --git a/src/Symfony/Component/Filesystem/Exception/ExceptionInterface.php b/src/Symfony/Component/Filesystem/Exception/ExceptionInterface.php index fc438d9f31..8f4f10aac7 100644 --- a/src/Symfony/Component/Filesystem/Exception/ExceptionInterface.php +++ b/src/Symfony/Component/Filesystem/Exception/ExceptionInterface.php @@ -16,6 +16,6 @@ namespace Symfony\Component\Filesystem\Exception; * * @author Romain Neutron */ -interface ExceptionInterface extends \Throwable +interface ExceptionInterface { } diff --git a/src/Symfony/Component/Form/Exception/ExceptionInterface.php b/src/Symfony/Component/Form/Exception/ExceptionInterface.php index 69145f0bcd..d455932edf 100644 --- a/src/Symfony/Component/Form/Exception/ExceptionInterface.php +++ b/src/Symfony/Component/Form/Exception/ExceptionInterface.php @@ -16,6 +16,6 @@ namespace Symfony\Component\Form\Exception; * * @author Bernhard Schussek */ -interface ExceptionInterface extends \Throwable +interface ExceptionInterface { } diff --git a/src/Symfony/Component/Intl/Exception/ExceptionInterface.php b/src/Symfony/Component/Intl/Exception/ExceptionInterface.php index 0a73682379..4fc076cafb 100644 --- a/src/Symfony/Component/Intl/Exception/ExceptionInterface.php +++ b/src/Symfony/Component/Intl/Exception/ExceptionInterface.php @@ -16,6 +16,6 @@ namespace Symfony\Component\Intl\Exception; * * @author Bernhard Schussek */ -interface ExceptionInterface extends \Throwable +interface ExceptionInterface { } diff --git a/src/Symfony/Component/Ldap/Exception/ExceptionInterface.php b/src/Symfony/Component/Ldap/Exception/ExceptionInterface.php index dbc4819e92..b861a3fe8d 100644 --- a/src/Symfony/Component/Ldap/Exception/ExceptionInterface.php +++ b/src/Symfony/Component/Ldap/Exception/ExceptionInterface.php @@ -16,6 +16,6 @@ namespace Symfony\Component\Ldap\Exception; * * @author Charles Sarrazin */ -interface ExceptionInterface extends \Throwable +interface ExceptionInterface { } diff --git a/src/Symfony/Component/Lock/Exception/ExceptionInterface.php b/src/Symfony/Component/Lock/Exception/ExceptionInterface.php index 30343f939e..0d41958474 100644 --- a/src/Symfony/Component/Lock/Exception/ExceptionInterface.php +++ b/src/Symfony/Component/Lock/Exception/ExceptionInterface.php @@ -16,6 +16,6 @@ namespace Symfony\Component\Lock\Exception; * * @author Jérémy Derussé */ -interface ExceptionInterface extends \Throwable +interface ExceptionInterface { } diff --git a/src/Symfony/Component/Messenger/Exception/ExceptionInterface.php b/src/Symfony/Component/Messenger/Exception/ExceptionInterface.php index 3a208deacc..56f665b9ee 100644 --- a/src/Symfony/Component/Messenger/Exception/ExceptionInterface.php +++ b/src/Symfony/Component/Messenger/Exception/ExceptionInterface.php @@ -16,6 +16,6 @@ namespace Symfony\Component\Messenger\Exception; * * @author Samuel Roze */ -interface ExceptionInterface extends \Throwable +interface ExceptionInterface { } diff --git a/src/Symfony/Component/OptionsResolver/Exception/ExceptionInterface.php b/src/Symfony/Component/OptionsResolver/Exception/ExceptionInterface.php index ea99d050e4..b62bb51d46 100644 --- a/src/Symfony/Component/OptionsResolver/Exception/ExceptionInterface.php +++ b/src/Symfony/Component/OptionsResolver/Exception/ExceptionInterface.php @@ -16,6 +16,6 @@ namespace Symfony\Component\OptionsResolver\Exception; * * @author Bernhard Schussek */ -interface ExceptionInterface extends \Throwable +interface ExceptionInterface { } diff --git a/src/Symfony/Component/Process/Exception/ExceptionInterface.php b/src/Symfony/Component/Process/Exception/ExceptionInterface.php index bd4a60403b..75c1c9e5d8 100644 --- a/src/Symfony/Component/Process/Exception/ExceptionInterface.php +++ b/src/Symfony/Component/Process/Exception/ExceptionInterface.php @@ -16,6 +16,6 @@ namespace Symfony\Component\Process\Exception; * * @author Johannes M. Schmitt */ -interface ExceptionInterface extends \Throwable +interface ExceptionInterface { } diff --git a/src/Symfony/Component/PropertyAccess/Exception/ExceptionInterface.php b/src/Symfony/Component/PropertyAccess/Exception/ExceptionInterface.php index fabf9a0802..d1fcdac942 100644 --- a/src/Symfony/Component/PropertyAccess/Exception/ExceptionInterface.php +++ b/src/Symfony/Component/PropertyAccess/Exception/ExceptionInterface.php @@ -16,6 +16,6 @@ namespace Symfony\Component\PropertyAccess\Exception; * * @author Bernhard Schussek */ -interface ExceptionInterface extends \Throwable +interface ExceptionInterface { } diff --git a/src/Symfony/Component/Routing/Exception/ExceptionInterface.php b/src/Symfony/Component/Routing/Exception/ExceptionInterface.php index 22e72b16bd..db7636211f 100644 --- a/src/Symfony/Component/Routing/Exception/ExceptionInterface.php +++ b/src/Symfony/Component/Routing/Exception/ExceptionInterface.php @@ -16,6 +16,6 @@ namespace Symfony\Component\Routing\Exception; * * @author Alexandre Salomé */ -interface ExceptionInterface extends \Throwable +interface ExceptionInterface { } diff --git a/src/Symfony/Component/Security/Core/Exception/ExceptionInterface.php b/src/Symfony/Component/Security/Core/Exception/ExceptionInterface.php index 7bc2b9132c..5000d02780 100644 --- a/src/Symfony/Component/Security/Core/Exception/ExceptionInterface.php +++ b/src/Symfony/Component/Security/Core/Exception/ExceptionInterface.php @@ -16,6 +16,6 @@ namespace Symfony\Component\Security\Core\Exception; * * @author Bernhard Schussek */ -interface ExceptionInterface extends \Throwable +interface ExceptionInterface { } diff --git a/src/Symfony/Component/Serializer/Exception/ExceptionInterface.php b/src/Symfony/Component/Serializer/Exception/ExceptionInterface.php index 859dcb4618..99ed63246c 100644 --- a/src/Symfony/Component/Serializer/Exception/ExceptionInterface.php +++ b/src/Symfony/Component/Serializer/Exception/ExceptionInterface.php @@ -16,6 +16,6 @@ namespace Symfony\Component\Serializer\Exception; * * @author Johannes M. Schmitt */ -interface ExceptionInterface extends \Throwable +interface ExceptionInterface { } diff --git a/src/Symfony/Component/Translation/Exception/ExceptionInterface.php b/src/Symfony/Component/Translation/Exception/ExceptionInterface.php index 8f9c54ef7a..c85fb93ca8 100644 --- a/src/Symfony/Component/Translation/Exception/ExceptionInterface.php +++ b/src/Symfony/Component/Translation/Exception/ExceptionInterface.php @@ -16,6 +16,6 @@ namespace Symfony\Component\Translation\Exception; * * @author Fabien Potencier */ -interface ExceptionInterface extends \Throwable +interface ExceptionInterface { } diff --git a/src/Symfony/Component/Validator/Exception/ExceptionInterface.php b/src/Symfony/Component/Validator/Exception/ExceptionInterface.php index 390e8c053f..77d09b9029 100644 --- a/src/Symfony/Component/Validator/Exception/ExceptionInterface.php +++ b/src/Symfony/Component/Validator/Exception/ExceptionInterface.php @@ -16,6 +16,6 @@ namespace Symfony\Component\Validator\Exception; * * @author Bernhard Schussek */ -interface ExceptionInterface extends \Throwable +interface ExceptionInterface { } diff --git a/src/Symfony/Component/Workflow/Exception/ExceptionInterface.php b/src/Symfony/Component/Workflow/Exception/ExceptionInterface.php index 5298262674..b0dfa9b79b 100644 --- a/src/Symfony/Component/Workflow/Exception/ExceptionInterface.php +++ b/src/Symfony/Component/Workflow/Exception/ExceptionInterface.php @@ -15,6 +15,6 @@ namespace Symfony\Component\Workflow\Exception; * @author Fabien Potencier * @author Grégoire Pineau */ -interface ExceptionInterface extends \Throwable +interface ExceptionInterface { } diff --git a/src/Symfony/Component/Yaml/Exception/ExceptionInterface.php b/src/Symfony/Component/Yaml/Exception/ExceptionInterface.php index 909131684c..ad850eea1d 100644 --- a/src/Symfony/Component/Yaml/Exception/ExceptionInterface.php +++ b/src/Symfony/Component/Yaml/Exception/ExceptionInterface.php @@ -16,6 +16,6 @@ namespace Symfony\Component\Yaml\Exception; * * @author Fabien Potencier */ -interface ExceptionInterface extends \Throwable +interface ExceptionInterface { } From 37270d79a2a72cfe9b1bfa5187cba72ba12402be Mon Sep 17 00:00:00 2001 From: Niels Keurentjes Date: Wed, 30 May 2018 01:32:15 +0200 Subject: [PATCH 16/22] Insert correct parameter_bag service in AbstractController --- .../Controller/AbstractController.php | 3 ++- .../Controller/AbstractControllerTest.php | 26 +++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Controller/AbstractController.php b/src/Symfony/Bundle/FrameworkBundle/Controller/AbstractController.php index 954961119e..b317786c68 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Controller/AbstractController.php +++ b/src/Symfony/Bundle/FrameworkBundle/Controller/AbstractController.php @@ -13,6 +13,7 @@ namespace Symfony\Bundle\FrameworkBundle\Controller; use Psr\Container\ContainerInterface; use Doctrine\Common\Persistence\ManagerRegistry; +use Symfony\Component\DependencyInjection\ParameterBag\ContainerBagInterface; use Symfony\Component\DependencyInjection\ServiceSubscriberInterface; use Symfony\Component\Form\FormFactoryInterface; use Symfony\Component\HttpFoundation\RequestStack; @@ -84,7 +85,7 @@ abstract class AbstractController implements ServiceSubscriberInterface 'form.factory' => '?'.FormFactoryInterface::class, 'security.token_storage' => '?'.TokenStorageInterface::class, 'security.csrf.token_manager' => '?'.CsrfTokenManagerInterface::class, - 'parameter_bag' => '?'.ContainerInterface::class, + 'parameter_bag' => '?'.ContainerBagInterface::class, 'message_bus' => '?'.MessageBusInterface::class, ); } diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/AbstractControllerTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/AbstractControllerTest.php index 77e92a09c0..0ae42c14ce 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/AbstractControllerTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/AbstractControllerTest.php @@ -24,6 +24,32 @@ class AbstractControllerTest extends ControllerTraitTest return new TestAbstractController(); } + /** + * This test protects the default subscribed core services against accidental modification. + */ + public function testSubscribedServices() + { + $subscribed = AbstractController::getSubscribedServices(); + $expectedServices = array( + 'router' => '?Symfony\\Component\\Routing\\RouterInterface', + 'request_stack' => '?Symfony\\Component\\HttpFoundation\\RequestStack', + 'http_kernel' => '?Symfony\\Component\\HttpKernel\\HttpKernelInterface', + 'serializer' => '?Symfony\\Component\\Serializer\\SerializerInterface', + 'session' => '?Symfony\\Component\\HttpFoundation\\Session\\SessionInterface', + 'security.authorization_checker' => '?Symfony\\Component\\Security\\Core\\Authorization\\AuthorizationCheckerInterface', + 'templating' => '?Symfony\\Component\\Templating\\EngineInterface', + 'twig' => '?Twig\\Environment', + 'doctrine' => '?Doctrine\\Common\\Persistence\\ManagerRegistry', + 'form.factory' => '?Symfony\\Component\\Form\\FormFactoryInterface', + 'parameter_bag' => '?Symfony\\Component\\DependencyInjection\\ParameterBag\\ContainerBagInterface', + 'message_bus' => '?Symfony\\Component\\Messenger\\MessageBusInterface', + 'security.token_storage' => '?Symfony\\Component\\Security\\Core\\Authentication\\Token\\Storage\\TokenStorageInterface', + 'security.csrf.token_manager' => '?Symfony\\Component\\Security\\Csrf\\CsrfTokenManagerInterface', + ); + + $this->assertEquals($expectedServices, $subscribed, 'Subscribed core services in AbstractController have changed'); + } + public function testGetParameter() { $container = new Container(new FrozenParameterBag(array('foo' => 'bar'))); From 1442c429f052c290d192250c2a411d94e9bb5f5f Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 30 May 2018 14:52:06 +0200 Subject: [PATCH 17/22] updated CHANGELOG for 4.1.0 --- CHANGELOG-4.1.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG-4.1.md b/CHANGELOG-4.1.md index a042563276..3f712a6dfd 100644 --- a/CHANGELOG-4.1.md +++ b/CHANGELOG-4.1.md @@ -7,6 +7,11 @@ in 4.1 minor versions. To get the diff for a specific change, go to https://github.com/symfony/symfony/commit/XXX where XXX is the change hash To get the diff between two versions, go to https://github.com/symfony/symfony/compare/v4.1.0...v4.1.1 +* 4.1.0 (2018-05-30) + + * bug #27420 Revert "feature #26702 Mark ExceptionInterfaces throwable (ostrolucky)" (nicolas-grekas) + * bug #27415 Insert correct parameter_bag service in AbstractController (curry684) + * 4.1.0-BETA3 (2018-05-26) * bug #27388 [Routing] Account for greediness when merging route patterns (nicolas-grekas) From 1d9e42269339b3a33ef12f0ead196a165bd3449c Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 30 May 2018 14:52:34 +0200 Subject: [PATCH 18/22] updated VERSION for 4.1.0 --- src/Symfony/Component/HttpKernel/Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/HttpKernel/Kernel.php b/src/Symfony/Component/HttpKernel/Kernel.php index 051ad7b5a0..3894f0a7c9 100644 --- a/src/Symfony/Component/HttpKernel/Kernel.php +++ b/src/Symfony/Component/HttpKernel/Kernel.php @@ -63,12 +63,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private $requestStackSize = 0; private $resetServices = false; - const VERSION = '4.1.0-DEV'; + const VERSION = '4.1.0'; const VERSION_ID = 40100; const MAJOR_VERSION = 4; const MINOR_VERSION = 1; const RELEASE_VERSION = 0; - const EXTRA_VERSION = 'DEV'; + const EXTRA_VERSION = ''; const END_OF_MAINTENANCE = '01/2019'; const END_OF_LIFE = '07/2019'; From 52647b86bfc15d579f9a894a49eb73140f45a19b Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 30 May 2018 15:07:50 +0200 Subject: [PATCH 19/22] bumped Symfony version to 4.1.1 --- src/Symfony/Component/HttpKernel/Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Component/HttpKernel/Kernel.php b/src/Symfony/Component/HttpKernel/Kernel.php index 3894f0a7c9..567268f2e1 100644 --- a/src/Symfony/Component/HttpKernel/Kernel.php +++ b/src/Symfony/Component/HttpKernel/Kernel.php @@ -63,12 +63,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private $requestStackSize = 0; private $resetServices = false; - const VERSION = '4.1.0'; - const VERSION_ID = 40100; + const VERSION = '4.1.1-DEV'; + const VERSION_ID = 40101; const MAJOR_VERSION = 4; const MINOR_VERSION = 1; - const RELEASE_VERSION = 0; - const EXTRA_VERSION = ''; + const RELEASE_VERSION = 1; + const EXTRA_VERSION = 'DEV'; const END_OF_MAINTENANCE = '01/2019'; const END_OF_LIFE = '07/2019'; From f5703dc6b3b01c549f9dc292887508b21c1238cd Mon Sep 17 00:00:00 2001 From: Maxime Steinhausser Date: Wed, 30 May 2018 19:32:47 +0200 Subject: [PATCH 20/22] [Messenger] Fix suggested enqueue adapter package --- src/Symfony/Component/Messenger/composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Messenger/composer.json b/src/Symfony/Component/Messenger/composer.json index adbd0e2a9f..8a34c564e6 100644 --- a/src/Symfony/Component/Messenger/composer.json +++ b/src/Symfony/Component/Messenger/composer.json @@ -30,7 +30,7 @@ "symfony/var-dumper": "~3.4|~4.0" }, "suggest": { - "sroze/enqueue-bridge": "For using the php-enqueue library as a transport." + "enqueue/messenger-adapter": "For using the php-enqueue library as a transport." }, "autoload": { "psr-4": { "Symfony\\Component\\Messenger\\": "" }, From c09ca94a284817b2876f2e5b2d7ead002dd925a1 Mon Sep 17 00:00:00 2001 From: DonCallisto Date: Wed, 30 May 2018 11:57:41 +0200 Subject: [PATCH 21/22] Update UPGRADE-4.0.md This https://github.com/symfony/symfony/blob/3.4/src/Symfony/Component/Security/Guard/Firewall/GuardAuthenticationListener.php#L127 was not reported. --- UPGRADE-3.4.md | 3 +++ UPGRADE-4.0.md | 3 +++ src/Symfony/Component/Security/CHANGELOG.md | 2 ++ 3 files changed, 8 insertions(+) diff --git a/UPGRADE-3.4.md b/UPGRADE-3.4.md index 765e5cf467..69dc6b000a 100644 --- a/UPGRADE-3.4.md +++ b/UPGRADE-3.4.md @@ -344,6 +344,9 @@ Security * The `GuardAuthenticatorInterface` has been deprecated and will be removed in 4.0. Use `AuthenticatorInterface` instead. + + * When extending `AbstractGuardAuthenticator` it's deprecated to return `null` from `getCredentials()`. + Return `false` from `supports()` if no credentials available. SecurityBundle -------------- diff --git a/UPGRADE-4.0.md b/UPGRADE-4.0.md index 14dc6f07a6..0e9e69ff80 100644 --- a/UPGRADE-4.0.md +++ b/UPGRADE-4.0.md @@ -758,6 +758,9 @@ Security * The `GuardAuthenticatorInterface` interface has been removed. Use `AuthenticatorInterface` instead. + + * When extending `AbstractGuardAuthenticator` getCredentials() cannot return + `null` anymore, return false from `supports()` if no credentials available instead. SecurityBundle -------------- diff --git a/src/Symfony/Component/Security/CHANGELOG.md b/src/Symfony/Component/Security/CHANGELOG.md index bd1b7b59eb..7ef21c0331 100644 --- a/src/Symfony/Component/Security/CHANGELOG.md +++ b/src/Symfony/Component/Security/CHANGELOG.md @@ -16,6 +16,8 @@ CHANGELOG * deprecated HTTP digest authentication * Added a new password encoder for the Argon2i hashing algorithm * deprecated `GuardAuthenticatorInterface` in favor of `AuthenticatorInterface` + * deprecated to return `null` from `getCredentials()` in classes that extend + `AbstractGuardAuthenticator`. Return `false` from `supports()` instead. 3.3.0 ----- From efe9beb1863f6a80fb975200c8dd6227d8f2befc Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Thu, 31 May 2018 12:02:37 +0200 Subject: [PATCH 22/22] [HttpKernel] Fix restoring trusted proxies in tests --- .../Tests/Processor/WebProcessorTest.php | 2 ++ .../HttpFoundation/Tests/RequestTest.php | 11 +------- .../ValidateRequestListenerTest.php | 5 ++++ .../Fragment/InlineFragmentRendererTest.php | 28 ++++++++++++++++--- .../Tests/HttpCache/HttpCacheTest.php | 2 ++ .../HttpKernel/Tests/HttpKernelTest.php | 2 ++ 6 files changed, 36 insertions(+), 14 deletions(-) diff --git a/src/Symfony/Bridge/Monolog/Tests/Processor/WebProcessorTest.php b/src/Symfony/Bridge/Monolog/Tests/Processor/WebProcessorTest.php index 51bddd1d98..6ce418d317 100644 --- a/src/Symfony/Bridge/Monolog/Tests/Processor/WebProcessorTest.php +++ b/src/Symfony/Bridge/Monolog/Tests/Processor/WebProcessorTest.php @@ -49,6 +49,8 @@ class WebProcessorTest extends TestCase $this->assertEquals($server['REQUEST_METHOD'], $record['extra']['http_method']); $this->assertEquals($server['SERVER_NAME'], $record['extra']['server']); $this->assertEquals($server['HTTP_REFERER'], $record['extra']['referrer']); + + Request::setTrustedProxies(array()); } public function testCanBeConstructedWithExtraFields() diff --git a/src/Symfony/Component/HttpFoundation/Tests/RequestTest.php b/src/Symfony/Component/HttpFoundation/Tests/RequestTest.php index 0080cf8ac5..3b65bcc99c 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/RequestTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/RequestTest.php @@ -20,6 +20,7 @@ class RequestTest extends TestCase { protected function tearDown() { + Request::setTrustedProxies(array()); Request::setTrustedHosts(array()); } @@ -750,8 +751,6 @@ class RequestTest extends TestCase )); $port = $request->getPort(); $this->assertEquals(80, $port, 'With only PROTO set and value is not recognized, getPort() defaults to 80.'); - - Request::setTrustedProxies(array()); } /** @@ -827,8 +826,6 @@ class RequestTest extends TestCase $request = $this->getRequestInstanceForClientIpTests($remoteAddr, $httpForwardedFor, $trustedProxies); $this->assertEquals($expected[0], $request->getClientIp()); - - Request::setTrustedProxies(array()); } /** @@ -839,8 +836,6 @@ class RequestTest extends TestCase $request = $this->getRequestInstanceForClientIpTests($remoteAddr, $httpForwardedFor, $trustedProxies); $this->assertEquals($expected, $request->getClientIps()); - - Request::setTrustedProxies(array()); } /** @@ -851,8 +846,6 @@ class RequestTest extends TestCase $request = $this->getRequestInstanceForClientIpsForwardedTests($remoteAddr, $httpForwarded, $trustedProxies); $this->assertEquals($expected, $request->getClientIps()); - - Request::setTrustedProxies(array()); } public function getClientIpsForwardedProvider() @@ -975,8 +968,6 @@ class RequestTest extends TestCase $clientIps = $request->getClientIps(); - Request::setTrustedProxies(array()); - $this->assertSame($expectedIps, $clientIps); } diff --git a/src/Symfony/Component/HttpKernel/Tests/EventListener/ValidateRequestListenerTest.php b/src/Symfony/Component/HttpKernel/Tests/EventListener/ValidateRequestListenerTest.php index 55dc59e13f..388f1b814b 100644 --- a/src/Symfony/Component/HttpKernel/Tests/EventListener/ValidateRequestListenerTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/EventListener/ValidateRequestListenerTest.php @@ -21,6 +21,11 @@ use Symfony\Component\HttpKernel\KernelEvents; class ValidateRequestListenerTest extends TestCase { + protected function tearDown() + { + Request::setTrustedProxies(array()); + } + /** * @expectedException \Symfony\Component\HttpFoundation\Exception\ConflictingHeadersException */ diff --git a/src/Symfony/Component/HttpKernel/Tests/Fragment/InlineFragmentRendererTest.php b/src/Symfony/Component/HttpKernel/Tests/Fragment/InlineFragmentRendererTest.php index 6ed3c86537..998b372181 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Fragment/InlineFragmentRendererTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/Fragment/InlineFragmentRendererTest.php @@ -56,7 +56,6 @@ class InlineFragmentRendererTest extends TestCase $subRequest->attributes->replace(array('object' => $object, '_format' => 'html', '_controller' => 'main_controller', '_locale' => 'en')); $subRequest->headers->set('x-forwarded-for', array('127.0.0.1')); $subRequest->server->set('HTTP_X_FORWARDED_FOR', '127.0.0.1'); - $subRequest->server->set('REMOTE_ADDR', '1.1.1.1'); $strategy = new InlineFragmentRenderer($this->getKernelExpectingRequest($subRequest)); @@ -85,7 +84,7 @@ class InlineFragmentRendererTest extends TestCase { Request::setTrustedHeaderName(Request::HEADER_CLIENT_IP, ''); - $strategy = new InlineFragmentRenderer($this->getKernelExpectingRequest(Request::create('/', 'GET', array(), array(), array(), array('REMOTE_ADDR' => '1.1.1.1')))); + $strategy = new InlineFragmentRenderer($this->getKernelExpectingRequest(Request::create('/'))); $this->assertSame('foo', $strategy->render('/', Request::create('/'))->getContent()); } @@ -169,7 +168,6 @@ class InlineFragmentRendererTest extends TestCase { $expectedSubRequest = Request::create('/'); $expectedSubRequest->headers->set('Surrogate-Capability', 'abc="ESI/1.0"'); - $expectedSubRequest->server->set('REMOTE_ADDR', '1.1.1.1'); if (Request::getTrustedHeaderName(Request::HEADER_CLIENT_IP)) { $expectedSubRequest->headers->set('x-forwarded-for', array('127.0.0.1')); @@ -195,7 +193,7 @@ class InlineFragmentRendererTest extends TestCase public function testHeadersPossiblyResultingIn304AreNotAssignedToSubrequest() { - $expectedSubRequest = Request::create('/', 'GET', array(), array(), array(), array('REMOTE_ADDR' => '1.1.1.1')); + $expectedSubRequest = Request::create('/'); if (Request::getTrustedHeaderName(Request::HEADER_CLIENT_IP)) { $expectedSubRequest->headers->set('x-forwarded-for', array('127.0.0.1')); $expectedSubRequest->server->set('HTTP_X_FORWARDED_FOR', '127.0.0.1'); @@ -206,6 +204,28 @@ class InlineFragmentRendererTest extends TestCase $strategy->render('/', $request); } + public function testFirstTrustedProxyIsSetAsRemote() + { + $expectedSubRequest = Request::create('/'); + $expectedSubRequest->headers->set('Surrogate-Capability', 'abc="ESI/1.0"'); + $expectedSubRequest->server->set('REMOTE_ADDR', '1.1.1.1'); + + if (Request::getTrustedHeaderName(Request::HEADER_CLIENT_IP)) { + $expectedSubRequest->headers->set('x-forwarded-for', array('127.0.0.1')); + $expectedSubRequest->server->set('HTTP_X_FORWARDED_FOR', '127.0.0.1'); + } + + Request::setTrustedProxies(array('1.1.1.1')); + + $strategy = new InlineFragmentRenderer($this->getKernelExpectingRequest($expectedSubRequest)); + + $request = Request::create('/'); + $request->headers->set('Surrogate-Capability', 'abc="ESI/1.0"'); + $strategy->render('/', $request); + + Request::setTrustedProxies(array()); + } + /** * Creates a Kernel expecting a request equals to $request * Allows delta in comparison in case REQUEST_TIME changed by 1 second. diff --git a/src/Symfony/Component/HttpKernel/Tests/HttpCache/HttpCacheTest.php b/src/Symfony/Component/HttpKernel/Tests/HttpCache/HttpCacheTest.php index d6902f4880..41c2d57833 100644 --- a/src/Symfony/Component/HttpKernel/Tests/HttpCache/HttpCacheTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/HttpCache/HttpCacheTest.php @@ -1315,6 +1315,8 @@ class HttpCacheTest extends HttpCacheTestCase $this->request('GET', '/', array('REMOTE_ADDR' => '10.0.0.1')); $this->assertEquals($expected, Request::getTrustedProxies()); + + Request::setTrustedProxies(array()); } public function getTrustedProxyData() diff --git a/src/Symfony/Component/HttpKernel/Tests/HttpKernelTest.php b/src/Symfony/Component/HttpKernel/Tests/HttpKernelTest.php index 448dc10cf1..22d9907e5c 100644 --- a/src/Symfony/Component/HttpKernel/Tests/HttpKernelTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/HttpKernelTest.php @@ -291,6 +291,8 @@ class HttpKernelTest extends TestCase $request->headers->set('X_FORWARDED_FOR', '3.3.3.3'); $kernel->handle($request, $kernel::MASTER_REQUEST, false); + + Request::setTrustedProxies(array()); } protected function getResolver($controller = null)