Skip to content

Commit 00b2f4e

Browse files
committed
bug #37362 [SecurityBundle] Drop cache.security_expression_language service if invalid (chalasr)
This PR was merged into the 4.4 branch. Discussion ---------- [SecurityBundle] Drop cache.security_expression_language service if invalid | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | - | License | MIT | Doc PR | - Definition should be removed when its parent (`cache.system`) does not exist. Spotted in #37337 Commits ------- bc96693 [SecurityBundle] Drop cache.security_expression_language definition if invalid
2 parents b690a4a + bc96693 commit 00b2f4e

File tree

3 files changed

+20
-7
lines changed

3 files changed

+20
-7
lines changed

src/Symfony/Bundle/SecurityBundle/DependencyInjection/Compiler/AddExpressionLanguageProvidersPass.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,9 @@ public function process(ContainerBuilder $container)
3333
$definition->addMethodCall('registerProvider', [new Reference($id)]);
3434
}
3535
}
36+
37+
if (!$container->hasDefinition('cache.system')) {
38+
$container->removeDefinition('cache.security_expression_language');
39+
}
3640
}
3741
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@
8787
<service id="security.user_checker" class="Symfony\Component\Security\Core\User\UserChecker" />
8888

8989
<service id="security.expression_language" class="Symfony\Component\Security\Core\Authorization\ExpressionLanguage">
90-
<argument type="service" id="cache.security_expression_language"></argument>
90+
<argument type="service" id="cache.security_expression_language" on-invalid="null" />
9191
</service>
9292

9393
<service id="security.authentication_utils" class="Symfony\Component\Security\Http\Authentication\AuthenticationUtils" public="true">

src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/CompleteConfigurationTest.php

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public function testUserProviders()
5656

5757
// chain provider
5858
$this->assertEquals([new IteratorArgument([
59-
new Reference('security.user.provider.concrete.service'),
59+
new Reference('user.manager'),
6060
new Reference('security.user.provider.concrete.basic'),
6161
])], $container->getDefinition('security.user.provider.concrete.chain')->getArguments());
6262
}
@@ -70,9 +70,9 @@ public function testFirewalls()
7070
foreach (array_keys($arguments[1]->getValues()) as $contextId) {
7171
$contextDef = $container->getDefinition($contextId);
7272
$arguments = $contextDef->getArguments();
73-
$listeners[] = array_map('strval', $arguments['index_0']->getValues());
73+
$listeners[] = array_map('strval', $arguments[0]->getValues());
7474

75-
$configDef = $container->getDefinition((string) $arguments['index_3']);
75+
$configDef = $container->getDefinition((string) $arguments[3]);
7676
$configs[] = array_values($configDef->getArguments());
7777
}
7878

@@ -87,6 +87,14 @@ public function testFirewalls()
8787
'security.user_checker',
8888
'.security.request_matcher.xmi9dcw',
8989
false,
90+
false,
91+
'',
92+
'',
93+
'',
94+
'',
95+
'',
96+
[],
97+
null,
9098
],
9199
[
92100
'secure',
@@ -657,9 +665,9 @@ public function testSimpleAuth()
657665
foreach (array_keys($arguments[1]->getValues()) as $contextId) {
658666
$contextDef = $container->getDefinition($contextId);
659667
$arguments = $contextDef->getArguments();
660-
$listeners[] = array_map('strval', $arguments['index_0']->getValues());
668+
$listeners[] = array_map('strval', $arguments[0]->getValues());
661669

662-
$configDef = $container->getDefinition((string) $arguments['index_3']);
670+
$configDef = $container->getDefinition((string) $arguments[3]);
663671
$configs[] = array_values($configDef->getArguments());
664672
}
665673

@@ -708,6 +716,8 @@ protected function getContainer($file)
708716

709717
$container = new ContainerBuilder();
710718
$container->setParameter('kernel.debug', false);
719+
$container->setParameter('request_listener.http_port', 80);
720+
$container->setParameter('request_listener.https_port', 443);
711721

712722
$security = new SecurityExtension();
713723
$container->registerExtension($security);
@@ -716,7 +726,6 @@ protected function getContainer($file)
716726
$bundle->build($container); // Attach all default factories
717727
$this->getLoader($container)->load($file);
718728

719-
$container->getCompilerPassConfig()->setOptimizationPasses([]);
720729
$container->getCompilerPassConfig()->setRemovingPasses([]);
721730
$container->getCompilerPassConfig()->setAfterRemovingPasses([]);
722731
$container->compile();

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy