Skip to content

Commit 8e5c98d

Browse files
bug #58518 [FrameworkBundle] Fix NullStore registration (HypeMC)
This PR was merged into the 7.2 branch. Discussion ---------- [FrameworkBundle] Fix `NullStore` registration | Q | A | ------------- | --- | Branch? | 7.2 | Bug fix? | yes | New feature? | no | Deprecations? | no | Issues | - | License | MIT Follow up to #58109 and #58445, cc `@xabbuh` I'm not sure if there's a way to get the XML config to work with the current schema as `null` is not interpreted as a string: ```xml <framework:resource name="garply">null</framework:resource> ``` Commits ------- cb528ebf967 [FrameworkBundle] Fix `NullStore` registration
2 parents 644603c + d609ce6 commit 8e5c98d

File tree

5 files changed

+8
-1
lines changed

5 files changed

+8
-1
lines changed

DependencyInjection/FrameworkExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2029,7 +2029,7 @@ private function registerLockConfiguration(array $config, ContainerBuilder $cont
20292029
$storeDefinitions = [];
20302030
foreach ($resourceStores as $resourceStore) {
20312031
$storeDsn = $container->resolveEnvPlaceholders($resourceStore, null, $usedEnvs);
2032-
if (!$usedEnvs && !str_contains($resourceStore, ':') && !\in_array($resourceStore, ['flock', 'semaphore', 'in-memory'], true)) {
2032+
if (!$usedEnvs && !str_contains($resourceStore, ':') && !\in_array($resourceStore, ['flock', 'semaphore', 'in-memory', 'null'], true)) {
20332033
$resourceStore = new Reference($resourceStore);
20342034
}
20352035
$storeDefinition = new Definition(PersistingStoreInterface::class);

Tests/DependencyInjection/Fixtures/php/lock_named.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,6 @@
1414
'qux' => '%env(REDIS_DSN)%',
1515
'corge' => 'in-memory',
1616
'grault' => 'mysql:host=localhost;dbname=test',
17+
'garply' => 'null',
1718
],
1819
]);

Tests/DependencyInjection/Fixtures/xml/lock_named.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
<framework:resource name="qux">%env(REDIS_DSN)%</framework:resource>
2121
<framework:resource name="corge">in-memory</framework:resource>
2222
<framework:resource name="grault">mysql:host=localhost;dbname=test</framework:resource>
23+
<framework:resource name="garply">null</framework:resource>
2324
</framework:lock>
2425
</framework:config>
2526
</container>

Tests/DependencyInjection/Fixtures/yml/lock_named.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ framework:
1414
qux: "%env(REDIS_DSN)%"
1515
corge: in-memory
1616
grault: mysql:host=localhost;dbname=test
17+
garply: 'null'

Tests/DependencyInjection/FrameworkExtensionTestCase.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2460,6 +2460,10 @@ public function testNamedLocks()
24602460
self::assertTrue($container->hasDefinition('lock.grault.factory'));
24612461
$storeDef = $container->getDefinition($container->getDefinition('lock.grault.factory')->getArgument(0));
24622462
self::assertSame('mysql:host=localhost;dbname=test', $storeDef->getArgument(0));
2463+
2464+
self::assertTrue($container->hasDefinition('lock.garply.factory'));
2465+
$storeDef = $container->getDefinition($container->getDefinition('lock.garply.factory')->getArgument(0));
2466+
self::assertSame('null', $storeDef->getArgument(0));
24632467
}
24642468

24652469
public function testLockWithService()

0 commit comments

Comments
 (0)