Skip to content

Commit 3ad682c

Browse files
greg0iremeyerbaptiste
authored andcommitted
Avoid creating potentially crashing service
This is broken since sf 3.4.4, see symfony/symfony#25823 One of api platforms listener depends on a file that now throws if it is loaded and the expression language component is missing. The solution is to avoid creating the service if the component is missing. This fixes an error people will have even if they do not use the access_control annotation attribute.
1 parent b3ff357 commit 3ad682c

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

src/Bridge/Symfony/Bundle/DependencyInjection/ApiPlatformExtension.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
use Symfony\Component\DependencyInjection\ContainerBuilder;
3434
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;
3535
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
36+
use Symfony\Component\ExpressionLanguage\ExpressionLanguage;
3637
use Symfony\Component\Finder\Finder;
3738
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
3839
use Symfony\Component\Validator\Validator\ValidatorInterface;
@@ -115,6 +116,9 @@ public function load(array $configs, ContainerBuilder $container)
115116

116117
$bundles = $container->getParameter('kernel.bundles');
117118
if (isset($bundles['SecurityBundle'])) {
119+
if (class_exists(ExpressionLanguage::class)) {
120+
$loader->load('security_expression_language.xml');
121+
}
118122
$loader->load('security.xml');
119123
}
120124

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
66

77
<services>
8-
<service id="api_platform.security.expression_language" class="ApiPlatform\Core\Security\ExpressionLanguage" public="false" />
9-
108
<service id="api_platform.security.resource_access_checker" class="ApiPlatform\Core\Security\ResourceAccessChecker" public="false">
119
<argument type="service" id="api_platform.security.expression_language" on-invalid="null" />
1210
<argument type="service" id="security.authentication.trust_resolver" on-invalid="null" />
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0" ?>
2+
3+
<container xmlns="http://symfony.com/schema/dic/services"
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
6+
<services>
7+
<service id="api_platform.security.expression_language" class="ApiPlatform\Core\Security\ExpressionLanguage" public="false" />
8+
</services>
9+
</container>

0 commit comments

Comments
 (0)