8000 Merge branch '4.0' into 4.1 · symfony/symfony@205b097 · GitHub
[go: up one dir, main page]

Skip to content

Commit 205b097

Browse files
Merge branch '4.0' into 4.1
* 4.0: (21 commits) [PropertyInfo] fix resolving parent|self type hints fixed CS fix merge [Security] Fix logout Cleanup 2 tests for the HttpException classes #27250 limiting GET_LOCK key up to 64 char due to changes in MySQL 5.7.5 and later [Config] Fix tests when path contains UTF chars [DI] Shared services should not be inlined in non-shared ones [Profiler] Remove propel & event_listener_loading category identifiers [Filesystem] Fix usages of error_get_last() [Cache][Lock] Fix usages of error_get_last() [Debug] Fix populating error_get_last() for handled silent errors fixed CS fixed CS fixed CS [FrameworkBundle] Fix cache:clear on vagrant [HttpKernel] Handle NoConfigurationException "onKernelException()" Fix misses calculation when calling getItems [DI] Display previous error messages when throwing unused bindings Fixed return type ...
2 parents f59ce97 + 544af2d commit 205b097

File tree

76 files changed

+504
-233
lines changed
  • Routing
  • Security
  • Serializer/Mapping
  • Translation
  • Validator
  • Some content is hidden

    Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

    76 files changed

    +504
    -233
    lines changed

    src/Symfony/Bridge/Monolog/Handler/FingersCrossed/NotFoundActivationStrategy.php

    Lines changed: 1 addition & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -42,7 +42,7 @@ public function isHandlerActivated(array $record)
    4242
    $isActivated
    4343
    && isset($record['context']['exception'])
    4444
    && $record['context']['exception'] instanceof HttpException
    45-
    && $record['context']['exception']->getStatusCode() == 404
    45+
    && 404 == $record['context']['exception']->getStatusCode()
    4646
    && ($request = $this->requestStack->getMasterRequest())
    4747
    ) {
    4848
    return !preg_match($this->blacklist, $request->getPathInfo());

    src/Symfony/Bridge/PhpUnit/Legacy/CoverageListenerTrait.php

    Lines changed: 0 additions & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -11,7 +11,6 @@
    1111

    1212
    namespace Symfony\Bridge\PhpUnit\Legacy;
    1313

    14-
    use PHPUnit\Framework\Test;
    1514
    use PHPUnit\Framework\TestCase;
    1615
    use PHPUnit\Framework\Warning;
    1716

    src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/weak_vendors_on_eval_d_deprecation.phpt

    Lines changed: 1 addition & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -15,7 +15,7 @@ while (!file_exists($vendor.'/vendor')) {
    1515
    define('PHPUNIT_COMPOSER_INSTALL', $vendor.'/vendor/autoload.php');
    1616
    require PHPUNIT_COMPOSER_INSTALL;
    1717
    require_once __DIR__.'/../../bootstrap.php';
    18-
    eval("@trigger_error('who knows where I come from?', E_USER_DEPRECATED);")
    18+
    eval("@trigger_error('who knows where I come from?', E_USER_DEPRECATED);");
    1919

    2020
    ?>
    2121
    --EXPECTF--

    src/Symfony/Bridge/Twig/NodeVisitor/Scope.php

    Lines changed: 1 addition & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -20,7 +20,7 @@ class Scope
    2020
    private $data = array();
    2121
    private $left = false;
    2222

    23-
    public function __construct(Scope $parent = null)
    23+
    public function __construct(self $parent = null)
    2424
    {
    2525
    $this->parent = $parent;
    2626
    }

    src/Symfony/Bundle/FrameworkBundle/Command/CacheClearCommand.php

    Lines changed: 24 additions & 6 deletions
    Original file line numberDiff line numberDiff line change
    @@ -129,15 +129,33 @@ protected function execute(InputInterface $input, OutputInterface $output)
    129129
    $this->warmup($warmupDir, $realCacheDir, !$input->getOption('no-optional-warmers'));
    130130
    }
    131131

    132-
    $containerDir = $fs->exists($warmupDir.'/'.$containerDir) ? false : $containerDir;
    132+
    if (!$fs->exists($warmupDir.'/'.$containerDir)) {
    133+
    $fs->rename($realCacheDir.'/'.$containerDir, $warmupDir.'/'.$containerDir);
    134+
    touch($warmupDir.'/'.$containerDir.'.legacy');
    135+
    }
    133136

    134-
    $fs->rename($realCacheDir, $oldCacheDir);
    135-
    $fs->rename($warmupDir, $realCacheDir);
    137+
    if ('/' === \DIRECTORY_SEPARATOR && $mounts = @file('/proc/mounts')) {
    138+
    foreach ($mounts as $mount) {
    139+
    $mount = array_slice(explode(' ', $mount), 1, -3);
    140+
    if (!\in_array(array_pop($mount), array('vboxfs', 'nfs'))) {
    141+
    continue;
    142+
    }
    143+
    $mount = implode(' ', $mount).'/';
    144+
    145+
    if (0 === strpos($realCacheDir, $mount)) {
    146+
    $io->note('For better performances, you should move the cache and log directories to a non-shared folder of the VM.');
    147+
    $oldCacheDir = false;
    148+
    break;
    149+
    }
    150+
    }
    151+
    }
    136152

    137-
    if ($containerDir) {
    138-
    $fs->rename($oldCacheDir.'/'.$containerDir, $realCacheDir.'/'.$containerDir);
    139-
    touch($realCacheDir.'/'.$containerDir.'.legacy');
    153+
    if ($oldCacheDir) {
    154+
    $fs->rename($realCacheDir, $oldCacheDir);
    155+
    } else {
    156+
    $fs->remove($realCacheDir);
    140157
    }
    158+
    $fs->rename($warmupDir, $realCacheDir);
    141159

    142160
    if ($output->isVerbose()) {
    143161
    $io->comment('Removing old cache directory...');

    src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerTest.php

    Lines changed: 0 additions & 1 deletion
    D306
    Original file line numberDiff line numberDiff line change
    @@ -12,7 +12,6 @@
    1212
    namespace Symfony\Bundle\FrameworkBundle\Tests\Controller;
    1313

    1414
    use Symfony\Bundle\FrameworkBundle\Controller\Controller;
    15-
    use Symfony\Component\HttpFoundation\File\File;
    1615

    1716
    class ControllerTest extends ControllerTraitTest
    1817
    {

    src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php

    Lines changed: 14 additions & 14 deletions
    Original file line numberDiff line numberDiff line change
    @@ -197,14 +197,15 @@ private function createFirewalls($config, ContainerBuilder $container)
    197197

    198198
    $configId = 'security.firewall.map.config.'.$name;
    199199

    200-
    list($matcher, $listeners, $exceptionListener) = $this->createFirewall($container, $name, $firewall, $authenticationProviders, $providerIds, $configId);
    200+
    list($matcher, $listeners, $exceptionListener, $logoutListener) = $this->createFirewall($container, $name, $firewall, $authenticationProviders, $providerIds, $configId);
    201201

    202202
    $contextId = 'security.firewall.map.context.'.$name;
    203203
    $context = $container->setDefinition($contextId, new ChildDefinition('security.firewall.context'));
    204204
    $context
    205205
    ->replaceArgument(0, new IteratorArgument($listeners))
    206206
    ->replaceArgument(1, $exceptionListener)
    207-
    ->replaceArgument(2, new Reference($configId))
    207+
    ->replaceArgument(2, $logoutListener)
    208+
    ->replaceArgument(3, new Reference($configId))
    208209
    ;
    209210

    210211
    $contextRefs[$contextId] = new Reference($contextId);
    @@ -250,7 +251,7 @@ private function createFirewall(ContainerBuilder $container, $id, $firewall, &$a
    250251

    251252
    // Security disabled?
    252253
    if (false === $firewall['security']) {
    253-
    return array($matcher, array(), null);
    254+
    return array($matcher, array(), null, null);
    254255
    }
    255256

    256257
    $config->replaceArgument(4, $firewall['stateless']);
    @@ -289,16 +290,15 @@ private function createFirewall(ContainerBuilder $container, $id, $firewall, &$a
    289290
    $config->replaceArgument(6, $contextKey);
    290291

    291292
    // Logout listener
    293+
    $logoutListenerId = null;
    292294
    if (isset($firewall['logout'])) {
    293-
    $listenerKeys[] = 'logout';
    294-
    $listenerId = 'security.logout_listener.'.$id;
    295-
    $listener = $container->setDefinition($listenerId, new ChildDefinition('security.logout_listener'));
    296-
    $listener->replaceArgument(3, array(
    295+
    $logoutListenerId = 'security.logout_listener.'.$id;
    296+
    $logoutListener = $container->setDefinition($logoutListenerId, new ChildDefinition('security.logout_listener'));
    297+
    $logoutListener->replaceArgument(3, array(
    297298
    'csrf_parameter' => $firewall['logout']['csrf_parameter'],
    298299
    'csrf_token_id' => $firewall['logout']['csrf_token_id'],
    299300
    'logout_path' => $firewall['logout']['path'],
    300301
    ));
    301-
    $listeners[] = new Reference($listenerId);
    302302

    303303
    // add logout success handler
    304304
    if (isset($firewall['logout']['success_handler'])) {
    @@ -308,16 +308,16 @@ private function createFirewall(ContainerBuilder $container, $id, $firewall, &$a
    308308
    $logoutSuccessHandler = $container->setDefinition($logoutSuccessHandlerId, new C462 ChildDefinition('security.logout.success_handler'));
    309309
    $logoutSuccessHandler->replaceArgument(1, $firewall['logout']['target']);
    310310
    }
    311-
    $listener->replaceArgument(2, new Reference($logoutSuccessHandlerId));
    311+
    $logoutListener->replaceArgument(2, new Reference($logoutSuccessHandlerId));
    312312

    313313
    // add CSRF provider
    314314
    if (isset($firewall['logout']['csrf_token_generator'])) {
    315-
    $listener->addArgument(new Reference($firewall['logout']['csrf_token_generator']));
    315+
    $logoutListener->addArgument(new Reference($firewall['logout']['csrf_token_generator']));
    316316
    }
    317317

    318318
    // add session logout handler
    319319
    if (true === $firewall['logout']['invalidate_session'] && false === $firewall['stateless']) {
    320-
    $listener->addMethodCall('addHandler', array(new Reference('security.logout.handler.session')));
    320+
    $logoutListener->addMethodCall('addHandler', array(new Reference('security.logout.handler.session')));
    321321
    }
    322322

    323323
    // add cookie logout handler
    @@ -326,12 +326,12 @@ private function createFirewall(ContainerBuilder $container, $id, $firewall, &$a
    326326
    $cookieHandler = $container->setDefinition($cookieHandlerId, new ChildDefinition('security.logout.handler.cookie_clearing'));
    327327
    $cookieHandler->addArgument($firewall['logout']['delete_cookies']);
    328328

    329-
    $listener->addMethodCall('addHandler', array(new Reference($cookieHandlerId)));
    329+
    $logoutListener->addMethodCall('addHandler', array(new Reference($cookieHandlerId)));
    330330
    }
    331331

    332332
    // add custom handlers
    333333
    foreach ($firewall['logout']['handlers'] as $handlerId) {
    334-
    $listener->addMethodCall('addHandler', array(new Reference($handlerId)));
    334+
    $logoutListener->addMethodCall('addHandler', array(new Reference($handlerId)));
    335335
    }
    336336

    337337
    // register with LogoutUrlGenerator
    @@ -391,7 +391,7 @@ private function createFirewall(ContainerBuilder $container, $id, $firewall, &$a
    391391
    $config->replaceArgument(10, $listenerKeys);
    392392
    $config->replaceArgument(11, isset($firewall['switch_user']) ? $firewall['switch_user'] : null);
    393393

    394-
    return array($matcher, $listeners, $exceptionListener);
    394+
    return array($matcher, $listeners, $exceptionListener, null !== $logoutListenerId ? new Reference($logoutListenerId) : null);
    395395
    }
    396396

    397397
    private function createContextListener($container, $contextKey)

    src/Symfony/Bundle/SecurityBundle/Resources/config/security.xml

    Lines changed: 1 addition & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -141,6 +141,7 @@
    141141
    <service id="security.firewall.context" class="Symfony\Bundle\SecurityBundle\Security\FirewallContext" abstract="true">
    142142
    <argument type="collection" />
    143143
    <argument type="service" id="security.exception_listener" />
    144+
    <argument /> <!-- LogoutListener -->
    144145
    <argument /> <!-- FirewallConfig -->
    145146
    </service>
    146147

    src/Symfony/Bundle/SecurityBundle/Security/FirewallContext.php

    Lines changed: 19 additions & 2 deletions
    Original file line numberDiff line numberDiff line change
    @@ -12,6 +12,7 @@
    1212
    namespace Symfony\Bundle\SecurityBundle\Security;
    1313

    1414
    use Symfony\Component\Security\Http\Firewall\ExceptionListener;
    15+
    use Symfony\Component\Security\Http\Firewall\LogoutListener;
    1516

    1617
    /**
    1718
    * This is a wrapper around the actual firewall configuration which allows us
    @@ -23,13 +24,24 @@ class FirewallContext
    2324
    {
    2425
    private $listeners;
    2526
    private $exceptionListener;
    27+
    private $logoutListener;
    2628
    private $config;
    2729

    28-
    public function __construct(iterable $listeners, ExceptionListener $exceptionListener = null, FirewallConfig $config = null)
    30+
    /**
    31+
    * @param LogoutListener|null $logoutListener
    32+
    */
    33+
    public function __construct(iterable $listeners, ExceptionListener $exceptionListener = null, $logoutListener = null, FirewallConfig $config = null)
    2934
    {
    3035
    $this->listeners = $listeners;
    3136
    $this->exceptionListener = $exceptionListener;
    32-
    $this->config = $config;
    37+
    if ($logoutListener instanceof FirewallConfig) {
    38+
    $this->config = $logoutListener;
    39+
    } elseif (null === $logoutListener || $logoutListener instanceof LogoutListener) {
    40+
    $this->logoutListener = $logoutListener;
    41+
    $this->config = $config;
    42+
    } else {
    43+
    throw new \InvalidArgumentException(sprintf('Argument 3 passed to %s() must be instance of %s or null, %s given.', __METHOD__, LogoutListener::class, is_object($logoutListener) ? get_class($logoutListener) : gettype($logoutListener)));
    44+
    }
    3345
    }
    3446

    3547
    public function getConfig()
    @@ -46,4 +58,9 @@ public function getExceptionListener()
    4658
    {
    4759
    return $this->exceptionListener;
    4860
    }
    61+
    62+
    public function getLogoutListener()
    63+
    {
    64+
    return $this->logoutListener;
    65+
    }
    4966
    }

    src/Symfony/Bundle/SecurityBundle/Security/FirewallMap.php

    Lines changed: 2 additions & 2 deletions
    Original file line numberDiff line numberDiff line change
    @@ -40,10 +40,10 @@ public function getListeners(Request $request)
    4040
    $context = $this->getFirewallContext($request);
    4141

    4242
    if (null === $context) {
    43-
    return array(array(), null);
    43+
    return array(array(), null, null);
    4444
    }
    4545

    46-
    return array($context->getListeners(), $context->getExceptionListener());
    46+
    return array($context->getListeners(), $context->getExceptionListener(), $context->getLogoutListener());
    4747
    }
    4848

    4949
    /**

    0 commit comments

    Comments
     (0)
    0