Skip to content
Permalink
Browse files

Merge branch '4.0' into 4.1

* 4.0:
  [HttpKernel] Fix restoring trusted proxies in tests
  Update UPGRADE-4.0.md
  CODEOWNERS: some more rules
  removed unneeded comments in tests
  removed unneeded comments in tests
  Change PHPDoc in ResponseHeaderBag::getCookies() to help IDEs
  [HttpKernel] fix registering IDE links
  [HttpKernel] Set first trusted proxy as REMOTE_ADDR in InlineFragmentRenderer.
  [Process] Consider \"executable\" suffixes first on Windows
  Triggering RememberMe's loginFail() when token cannot be created
  [Serializer] Fix serializer tries to denormalize null values on nullable properties
  [FrameworkBundle] Change priority of AddConsoleCommandPass to TYPE_BEFORE_REMOVING
  • Loading branch information...
nicolas-grekas committed May 31, 2018
2 parents 3d3d5c4 + b2e93cf commit 8bbd7389a3198a8403137a095d17ab9fbf9399b6
Showing with 280 additions and 86 deletions.
  1. +13 −0 .github/CODEOWNERS
  2. +3 −0 UPGRADE-4.0.md
  3. +2 −2 UPGRADE-4.1.md
  4. +2 −0 src/Symfony/Bridge/Monolog/Tests/Processor/WebProcessorTest.php
  5. +1 −4 src/Symfony/Bundle/FrameworkBundle/FrameworkBundle.php
  6. +1 −0 src/Symfony/Bundle/FrameworkBundle/Resources/config/web.xml
  7. +1 −0 src/Symfony/Bundle/WebProfilerBundle/Controller/ExceptionController.php
  8. +79 −4 src/Symfony/Component/Console/Tests/DependencyInjection/AddConsoleCommandPassTest.php
  9. +1 −1 src/Symfony/Component/HttpFoundation/ResponseHeaderBag.php
  10. +0 −1 src/Symfony/Component/HttpFoundation/Tests/RequestTest.php
  11. +4 −2 src/Symfony/Component/HttpKernel/EventListener/ExceptionListener.php
  12. +3 −1 src/Symfony/Component/HttpKernel/Fragment/InlineFragmentRenderer.php
  13. +5 −0 src/Symfony/Component/HttpKernel/Tests/EventListener/ValidateRequestListenerTest.php
  14. +21 −4 src/Symfony/Component/HttpKernel/Tests/Fragment/InlineFragmentRendererTest.php
  15. +2 −0 src/Symfony/Component/HttpKernel/Tests/HttpCache/HttpCacheTest.php
  16. +2 −0 src/Symfony/Component/HttpKernel/Tests/HttpKernelTest.php
  17. +0 −64 src/Symfony/Component/OptionsResolver/Tests/OptionsResolverTest.php
  18. +1 −1 src/Symfony/Component/Process/ExecutableFinder.php
  19. +30 −0 src/Symfony/Component/Process/Tests/ExecutableFinderTest.php
  20. +3 −1 src/Symfony/Component/Security/CHANGELOG.md
  21. +19 −1 src/Symfony/Component/Security/Http/Firewall/RememberMeListener.php
  22. +37 −0 src/Symfony/Component/Security/Http/Tests/Firewall/RememberMeListenerTest.php
  23. +6 −0 src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php
  24. +32 −0 src/Symfony/Component/Serializer/Tests/Fixtures/NullableConstructorArgumentDummy.php
  25. +12 −0 src/Symfony/Component/Serializer/Tests/Normalizer/AbstractNormalizerTest.php
@@ -1,10 +1,23 @@
# 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
/src/Symfony/Component/Lock/* @jderusse
# 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
@@ -759,6 +759,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
--------------

@@ -64,8 +64,8 @@ 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.
* 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
---------------
@@ -49,6 +49,8 @@ public function testUseRequestClientIp()
$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(), -1);
}
public function testCanBeConstructedWithExtraFields()
@@ -64,9 +64,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->getParameter('kernel.http_method_override')) {
@@ -102,7 +99,7 @@ public function build(ContainerBuilder $container)
$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);
$this->addCompilerPassIfExists($container, TranslatorPass::class);
$container->addCompilerPass(new LoggingTranslatorPass());
$container->addCompilerPass(new AddExpressionLanguageProvidersPass());
@@ -74,6 +74,7 @@
<argument type="service" id="logger" on-invalid="null" />
<argument>%kernel.debug%</argument>
<argument>%kernel.charset%</argument>
<argument>%debug.file_link_format%</argument>
</service>

<service id="validate_request_listener" class="Symfony\Component\HttpKernel\EventListener\ValidateRequestListener">
@@ -30,6 +30,7 @@ class ExceptionController
protected $twig;
protected $debug;
protected $profiler;
private $fileLinkFormat;
public function __construct(Profiler $profiler = null, Environment $twig, bool $debug, FileLinkFormatter $fileLinkFormat = null)
{
@@ -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');
$id = 'my-command';
@@ -124,7 +126,7 @@ public function testProcessThrowAnExceptionIfTheServiceIsAbstract()
{
$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');
@@ -142,7 +144,7 @@ public function testProcessThrowAnExceptionIfTheServiceIsNotASubclassOfCommand()
{
$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');
@@ -171,6 +173,79 @@ public function testProcessPrivateServicesWithSameCommand()
$this->assertTrue($container->hasAlias($aliasPrefix.'my-command1'));
$this->assertTrue($container->hasAlias($aliasPrefix.'my-command2'));
}
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
@@ -210,7 +210,7 @@ public function removeCookie($name, $path = '/', $domain = null)
*
* @param string $format
*
* @return array
* @return Cookie[]
*
* @throws \InvalidArgumentException When the $format is invalid
*/
@@ -21,7 +21,6 @@ class RequestTest extends TestCase
{
protected function tearDown()
{
// reset
Request::setTrustedProxies(array(), -1);
Request::setTrustedHosts(array());
}
@@ -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 logKernelException(GetResponseForExceptionEvent $event)
@@ -130,7 +132,7 @@ protected function duplicateRequest(\Exception $exception, Request $request)
$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());
},
@@ -115,7 +115,9 @@ protected function createSubRequest($uri, Request $request)
$server['HTTP_X_FORWARDED_FOR'] = ($currentXForwardedFor ? $currentXForwardedFor.', ' : '').$request->getClientIp();
}
$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']);
@@ -21,6 +21,11 @@
class ValidateRequestListenerTest extends TestCase
{
protected function tearDown()
{
Request::setTrustedProxies(array(), -1);
}
/**
* @expectedException \Symfony\Component\HttpFoundation\Exception\ConflictingHeadersException
*/
@@ -168,16 +168,33 @@ public function testESIHeaderIsKeptInSubrequestWithTrustedHeaderDisabled()
public function testHeadersPossiblyResultingIn304AreNotAssignedToSubrequest()
{
$expectedSubRequest = Request::create('/');
if (Request::HEADER_X_FORWARDED_FOR & Request::getTrustedHeaderSet()) {
$expectedSubRequest->headers->set('x-forwarded-for', array('127.0.0.1'));
$expectedSubRequest->server->set('HTTP_X_FORWARDED_FOR', '127.0.0.1');
}
$expectedSubRequest->headers->set('x-forwarded-for', array('127.0.0.1'));
$expectedSubRequest->server->set('HTTP_X_FORWARDED_FOR', '127.0.0.1');
$strategy = new InlineFragmentRenderer($this->getKernelExpectingRequest($expectedSubRequest));
$request = Request::create('/', 'GET', array(), array(), array(), array('HTTP_IF_MODIFIED_SINCE' => 'Fri, 01 Jan 2016 00:00:00 GMT', 'HTTP_IF_NONE_MATCH' => '*'));
$strategy->render('/', $request);
}
public function testFirstTrustedProxyIsSetAsRemote()
{
Request::setTrustedProxies(array('1.1.1.1'), -1);
$expectedSubRequest = Request::create('/');
$expectedSubRequest->headers->set('Surrogate-Capability', 'abc="ESI/1.0"');
$expectedSubRequest->server->set('REMOTE_ADDR', '1.1.1.1');
$expectedSubRequest->headers->set('x-forwarded-for', array('127.0.0.1'));
$expectedSubRequest->server->set('HTTP_X_FORWARDED_FOR', '127.0.0.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(), -1);
}
/**
* Creates a Kernel expecting a request equals to $request
* Allows delta in comparison in case REQUEST_TIME changed by 1 second.
@@ -1350,6 +1350,8 @@ public function testHttpCacheIsSetAsATrustedProxy(array $existing, array $expect
$this->request('GET', '/', array('REMOTE_ADDR' => '10.0.0.1'));
$this->assertEquals($expected, Request::getTrustedProxies());
Request::setTrustedProxies(array(), -1);
}
public function getTrustedProxyData()
@@ -331,6 +331,8 @@ public function testInconsistentClientIpsOnMasterRequests()
$kernel = $this->getHttpKernel($dispatcher);
$kernel->handle($request, $kernel::MASTER_REQUEST, false);
Request::setTrustedProxies(array(), -1);
}
private function getHttpKernel(EventDispatcherInterface $eventDispatcher, $controller = null, RequestStack $requestStack = null, array $arguments = array())
Oops, something went wrong.

0 comments on commit 8bbd738

Please sign in to comment.
You can’t perform that action at this time.