From cb528ebf96722759c332724f6d8800664a9bdab9 Mon Sep 17 00:00:00 2001 From: HypeMC Date: Thu, 10 Oct 2024 10:12:22 +0200 Subject: [PATCH] [FrameworkBundle] Fix `NullStore` registration --- .../DependencyInjection/FrameworkExtension.php | 2 +- .../Tests/DependencyInjection/Fixtures/php/lock_named.php | 1 + .../Tests/DependencyInjection/Fixtures/xml/lock_named.xml | 1 + .../Tests/DependencyInjection/Fixtures/yml/lock_named.yml | 1 + .../Tests/DependencyInjection/FrameworkExtensionTestCase.php | 4 ++++ 5 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php index 1393797711883..62277c9bbf166 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php @@ -2029,7 +2029,7 @@ private function registerLockConfiguration(array $config, ContainerBuilder $cont $storeDefinitions = []; foreach ($resourceStores as $resourceStore) { $storeDsn = $container->resolveEnvPlaceholders($resourceStore, null, $usedEnvs); - if (!$usedEnvs && !str_contains($resourceStore, ':') && !\in_array($resourceStore, ['flock', 'semaphore', 'in-memory'], true)) { + if (!$usedEnvs && !str_contains($resourceStore, ':') && !\in_array($resourceStore, ['flock', 'semaphore', 'in-memory', 'null'], true)) { $resourceStore = new Reference($resourceStore); } $storeDefinition = new Definition(PersistingStoreInterface::class); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/lock_named.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/lock_named.php index cbfead83000a3..c03a7fa71aa75 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/lock_named.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/lock_named.php @@ -14,5 +14,6 @@ 'qux' => '%env(REDIS_DSN)%', 'corge' => 'in-memory', 'grault' => 'mysql:host=localhost;dbname=test', + 'garply' => 'null', ], ]); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/lock_named.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/lock_named.xml index 7c48fa447f59c..b8d4b4a3fe347 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/lock_named.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/lock_named.xml @@ -20,6 +20,7 @@ %env(REDIS_DSN)% in-memory mysql:host=localhost;dbname=test + null diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/lock_named.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/lock_named.yml index 04ec9fc07f740..63157403069c1 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/lock_named.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/lock_named.yml @@ -14,3 +14,4 @@ framework: qux: "%env(REDIS_DSN)%" corge: in-memory grault: mysql:host=localhost;dbname=test + garply: 'null' diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTestCase.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTestCase.php index 4bccbb71ff601..016ae507badc8 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTestCase.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTestCase.php @@ -2460,6 +2460,10 @@ public function testNamedLocks() self::assertTrue($container->hasDefinition('lock.grault.factory')); $storeDef = $container->getDefinition($container->getDefinition('lock.grault.factory')->getArgument(0)); self::assertSame('mysql:host=localhost;dbname=test', $storeDef->getArgument(0)); + + self::assertTrue($container->hasDefinition('lock.garply.factory')); + $storeDef = $container->getDefinition($container->getDefinition('lock.garply.factory')->getArgument(0)); + self::assertSame('null', $storeDef->getArgument(0)); } public function testLockWithService()