From ff6792509f23b2fca1707c0990910cce151b9968 Mon Sep 17 00:00:00 2001 From: Maxcastel Date: Fri, 2 Jan 2026 19:27:57 +0100 Subject: [PATCH] chore: deprecate link_security and set it default to true --- .../Bundle/DependencyInjection/ApiPlatformExtension.php | 4 +--- src/Symfony/Bundle/DependencyInjection/Configuration.php | 6 +++++- tests/Fixtures/app/config/config_common.yml | 1 + .../Bundle/DependencyInjection/ConfigurationTest.php | 3 ++- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/Symfony/Bundle/DependencyInjection/ApiPlatformExtension.php b/src/Symfony/Bundle/DependencyInjection/ApiPlatformExtension.php index 9ce057e1d9..da70b28a69 100644 --- a/src/Symfony/Bundle/DependencyInjection/ApiPlatformExtension.php +++ b/src/Symfony/Bundle/DependencyInjection/ApiPlatformExtension.php @@ -995,9 +995,7 @@ private function registerArgumentResolverConfiguration(PhpFileLoader $loader): v private function registerLinkSecurityConfiguration(PhpFileLoader $loader, array $config): void { - if ($config['enable_link_security']) { - $loader->load('link_security.php'); - } + $loader->load('link_security.php'); } private function registerJsonStreamerConfiguration(ContainerBuilder $container, PhpFileLoader $loader, array $formats, array $config): void diff --git a/src/Symfony/Bundle/DependencyInjection/Configuration.php b/src/Symfony/Bundle/DependencyInjection/Configuration.php index acd75f2d93..5c2c06e96f 100644 --- a/src/Symfony/Bundle/DependencyInjection/Configuration.php +++ b/src/Symfony/Bundle/DependencyInjection/Configuration.php @@ -117,7 +117,11 @@ public function getConfigTreeBuilder(): TreeBuilder ->booleanNode('enable_docs')->defaultTrue()->info('Enable the docs')->end() ->booleanNode('enable_profiler')->defaultTrue()->info('Enable the data collector and the WebProfilerBundle integration.')->end() ->booleanNode('enable_phpdoc_parser')->defaultTrue()->info('Enable resource metadata collector using PHPStan PhpDocParser.')->end() - ->booleanNode('enable_link_security')->defaultFalse()->info('Enable security for Links (sub resources)')->end() + ->booleanNode('enable_link_security') + ->defaultTrue() + ->info('Enable security for Links (sub resources).') + ->setDeprecated('api-platform/symfony', '4.2', 'This option is always enabled and will be removed in API Platform 5.0.') + ->end() ->arrayNode('collection') ->addDefaultsIfNotSet() ->children() diff --git a/tests/Fixtures/app/config/config_common.yml b/tests/Fixtures/app/config/config_common.yml index eb58c616ae..bad87b0a41 100644 --- a/tests/Fixtures/app/config/config_common.yml +++ b/tests/Fixtures/app/config/config_common.yml @@ -82,6 +82,7 @@ api_platform: http_cache: invalidation: enabled: true + # TODO: remove in 5.0 enable_link_security: true # see also defaults in AppKernel doctrine_mongodb_odm: false diff --git a/tests/Symfony/Bundle/DependencyInjection/ConfigurationTest.php b/tests/Symfony/Bundle/DependencyInjection/ConfigurationTest.php index 657c418871..7c8725b4a2 100644 --- a/tests/Symfony/Bundle/DependencyInjection/ConfigurationTest.php +++ b/tests/Symfony/Bundle/DependencyInjection/ConfigurationTest.php @@ -233,7 +233,8 @@ private function runDefaultConfigTests(array $doctrineIntegrationsToLoad = ['orm ], 'use_symfony_listeners' => false, 'handle_symfony_errors' => false, - 'enable_link_security' => false, + // TODO: remove in 5.0 + 'enable_link_security' => true, 'serializer' => [ 'hydra_prefix' => null, ],