Skip to content

Commit 80cdda8

Browse files
Merge branch '3.4' into 4.4
* 3.4: Fix versions [Security/Http] Allow setting cookie security settings for delete_cookies [FrameworkBundle] revert to legacy wiring of the session when circular refs are detected bumped Symfony version to 3.4.40 updated VERSION for 3.4.39 update CONTRIBUTORS for 3.4.39 updated CHANGELOG for 3.4.39 update Italian translation [Validator] Add missing Hungarian translations [Validator] Add the missing translations for the Arabic (ar) locale [Validator] Add missing vietnamese translations [Console] Fix OutputStream for PHP 7.4 add German translations bug #36157 [Validator] Assert Valid with many groups [Validator] Add missing Lithuanian translations Fixed some typos Add french "at least" constraint translations
2 parents 4c50287 + c085e56 commit 80cdda8

File tree

4 files changed

+98
-2
lines changed

4 files changed

+98
-2
lines changed

Console/Descriptor/XmlDescriptor.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -383,8 +383,8 @@ private function getArgumentNodes(array $arguments, \DOMDocument $dom): array
383383
} elseif (\is_array($argument)) {
384384
$argumentXML->setAttribute('type', 'collection');
385385

386-
foreach ($this->getArgumentNodes($argument, $dom) as $childArgumenXML) {
387-
$argumentXML->appendChild($childArgumenXML);
386+
foreach ($this->getArgumentNodes($argument, $dom) as $childArgumentXML) {
387+
$argumentXML->appendChild($childArgumentXML);
388388
}
389389
} else {
390390
$argumentXML->appendChild(new \DOMText($argument));
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler;
13+
14+
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
15+
use Symfony\Component\DependencyInjection\ContainerBuilder;
16+
use Symfony\Component\DependencyInjection\Reference;
17+
18+
/**
19+
* @internal to be removed in 6.0
20+
*/
21+
class SessionPass implements CompilerPassInterface
22+
{
23+
public function process(ContainerBuilder $container)
24+
{
25+
if (!$container->hasDefinition('session')) {
26+
return;
27+
}
28+
29+
$bags = [
30+
'session.flash_bag' => $container->hasDefinition('session.flash_bag') ? $container->getDefinition('session.flash_bag') : null,
31+
'session.attribute_bag' => $container->hasDefinition('session.attribute_bag') ? $container->getDefinition('session.attribute_bag') : null,
32+
];
33+
34+
foreach ($container->getDefinition('session')->getArguments() as $v) {
35+
if (!$v instanceof Reference || !isset($bags[$bag = (string) $v]) || !\is_array($factory = $bags[$bag]->getFactory())) {
36+
continue;
37+
}
38+
39+
if ([0, 1] !== array_keys($factory) || !$factory[0] instanceof Reference || 'session' !== (string) $factory[0]) {
40+
continue;
41+
}
42+
43+
if ('get'.ucfirst(substr($bag, 8, -4)).'Bag' !== $factory[1]) {
44+
continue;
45+
}
46+
47+
$bags[$bag]->setFactory(null);
48+
}
49+
}
50+
}

FrameworkBundle.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\DataCollectorTranslatorPass;
1919
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\LoggingTranslatorPass;
2020
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\ProfilerPass;
21+
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\SessionPass;
2122
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\TemplatingPass;
2223
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\TestServiceContainerRealRefPass;
2324
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\TestServiceContainerWeakRefPass;
@@ -151,6 +152,7 @@ public function build(ContainerBuilder $container)
151152
$this->addCompilerPassIfExists($container, AddAutoMappingConfigurationPass::class);
152153
$container->addCompilerPass(new RegisterReverseContainerPass(true));
153154
$container->addCompilerPass(new RegisterReverseContainerPass(false), PassConfig::TYPE_AFTER_REMOVING);
155+
$container->addCompilerPass(new SessionPass());
154156

155157
if ($container->getParameter('kernel.debug')) {
156158
$container->addCompilerPass(new AddDebugLogProcessorPass(), PassConfig::TYPE_BEFORE_OPTIMIZATION, 2);
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\Compiler;
13+
14+
use PHPUnit\Framework\TestCase;
15+
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\SessionPass;
16+
use Symfony\Component\DependencyInjection\ContainerBuilder;
17+
use Symfony\Component\DependencyInjection\Reference;
18+
19+
class SessionPassTest extends TestCase
20+
{
21+
public function testProcess()
22+
{
23+
$arguments = [
24+
new Reference('session.flash_bag'),
25+
new Reference('session.attribute_bag'),
26+
];
27+
$container = new ContainerBuilder();
28+
$container
29+
->register('session')
30+
->setArguments($arguments);
31+
$container
32+
->register('session.flash_bag')
33+
->setFactory([new Reference('session'), 'getFlashBag']);
34+
$container
35+
->register('session.attribute_bag')
36+
->setFactory([new Reference('session'), 'getAttributeBag']);
37+
38+
(new SessionPass())->process($container);
39+
40+
$this->assertSame($arguments, $container->getDefinition('session')->getArguments());
41+
$this->assertNull($container->getDefinition('session.flash_bag')->getFactory());
42+
$this->assertNull($container->getDefinition('session.attribute_bag')->getFactory());
43+
}
44+
}

0 commit comments

Comments
 (0)