Skip to content

Commit 3957a98

Browse files
committed
Fixes
1 parent 7d0320e commit 3957a98

File tree

4 files changed

+15
-3
lines changed

4 files changed

+15
-3
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ public function process(ContainerBuilder $container)
3636

3737
if (!$container->hasDefinition('cache.system')) {
3838
$container->removeDefinition('cache.security_expression_language');
39+
$container->removeDefinition('cache.security_is_granted_attribute_expression_language');
3940
}
4041
}
4142
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ public function load(array $configs, ContainerBuilder $container)
112112
if (!$container::willBeAvailable('symfony/expression-language', ExpressionLanguage::class, ['symfony/security-bundle'])) {
113113
$container->removeDefinition('security.expression_language');
114114
$container->removeDefinition('security.access.expression_voter');
115+
$container->removeDefinition('security.is_granted_attribute_expression_language');
115116
}
116117

117118
// set some global scalars

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use Symfony\Bundle\SecurityBundle\Security\FirewallMap;
1919
use Symfony\Bundle\SecurityBundle\Security\LazyFirewallContext;
2020
use Symfony\Bundle\SecurityBundle\Security\Security;
21+
use Symfony\Component\ExpressionLanguage\ExpressionLanguage as BaseExpressionLanguage;
2122
use Symfony\Component\Ldap\Security\LdapUserProvider;
2223
use Symfony\Component\Security\Core\Authentication\AuthenticationTrustResolver;
2324
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage;
@@ -277,8 +278,16 @@
277278
->set('controller.is_granted_attribute_listener', IsGrantedAttributeListener::class)
278279
->args([
279280
service('security.authorization_checker'),
280-
service('security.expression_language')->nullOnInvalid(),
281+
service('security.is_granted_attribute_expression_language')->nullOnInvalid(),
281282
])
282283
->tag('kernel.event_subscriber')
284+
285+
->set('security.is_granted_attribute_expression_language', BaseExpressionLanguage::class)
286+
->args([service('cache.security_is_granted_attribute_expression_language')->nullOnInvalid()])
287+
288+
->set('cache.security_is_granted_attribute_expression_language')
289+
->parent('cache.system')
290+
->private()
291+
->tag('cache.pool')
283292
;
284293
};

src/Symfony/Component/Security/Http/EventListener/IsGrantedAttributeListener.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,13 @@
1313

1414
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
1515
use Symfony\Component\ExpressionLanguage\Expression;
16+
use Symfony\Component\ExpressionLanguage\ExpressionLanguage;
1617
use Symfony\Component\HttpKernel\Event\ControllerArgumentsEvent;
1718
use Symfony\Component\HttpKernel\Exception\HttpException;
1819
use Symfony\Component\HttpKernel\KernelEvents;
1920
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
20-
use Symfony\Component\Security\Core\Authorization\ExpressionLanguage;
2121
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
22+
use Symfony\Component\Security\Core\Exception\LogicException;
2223
use Symfony\Component\Security\Core\Exception\RuntimeException;
2324
use Symfony\Component\Security\Http\Attribute\IsGranted;
2425

@@ -52,7 +53,7 @@ public function onKernelControllerArguments(ControllerArgumentsEvent $event)
5253
if ($subjectRef instanceof Expression) {
5354
$this->expressionLanguage ??= class_exists(Expression::class)
5455
? new ExpressionLanguage()
55-
: throw new \LogicException('Unable to use expressions as the Symfony ExpressionLanguage component is not installed. Try running "composer require symfony/expression-language".')
56+
: throw new LogicException('Unable to use expressions as the Symfony ExpressionLanguage component is not installed. Try running "composer require symfony/expression-language".')
5657
;
5758
$subject = $this->expressionLanguage->evaluate($subjectRef, [
5859
'args' => $arguments,

0 commit comments

Comments
 (0)