Skip to content

Commit de6a50c

Browse files
committed
bug #39686 [Lock] Fix config merging in lock (jderusse)
This PR was merged into the 4.4 branch. Discussion ---------- [Lock] Fix config merging in lock | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fix #35920 | License | MIT | Doc PR | - Commits ------- 6bb2d67cf1 Fix config merging in lock
2 parents 98c3d02 + 3230ade commit de6a50c

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

DependencyInjection/Configuration.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1122,6 +1122,8 @@ private function addLockSection(ArrayNodeDefinition $rootNode)
11221122
->fixXmlConfig('resource')
11231123
->children()
11241124
->arrayNode('resources')
1125+
->normalizeKeys(false)
1126+
->useAttributeAsKey('name')
11251127
->requiresAtLeastOneElement()
11261128
->defaultValue(['default' => [class_exists(SemaphoreStore::class) && SemaphoreStore::isSupported() ? 'semaphore' : 'flock']])
11271129
->beforeNormalization()
@@ -1144,6 +1146,7 @@ private function addLockSection(ArrayNodeDefinition $rootNode)
11441146
})
11451147
->end()
11461148
->prototype('array')
1149+
->performNoDeepMerging()
11471150
->beforeNormalization()->ifString()->then(function ($v) { return [$v]; })->end()
11481151
->prototype('scalar')->end()
11491152
->end()

Tests/DependencyInjection/ConfigurationTest.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,34 @@ public function provideValidLockConfigurationTests()
250250
yield [['enabled' => false, 'resource' => [['name' => 'foo', 'value' => 'flock'], ['name' => 'foo', 'value' => 'semaphore'], ['name' => 'bar', 'value' => 'semaphore']]], ['enabled' => false, 'resources' => ['foo' => ['flock', 'semaphore'], 'bar' => ['semaphore']]]];
251251
}
252252

253+
public function testLockMergeConfigs()
254+
{
255+
$processor = new Processor();
256+
$configuration = new Configuration(true);
257+
$config = $processor->processConfiguration($configuration, [
258+
[
259+
'lock' => [
260+
'payload' => 'flock',
261+
],
262+
],
263+
[
264+
'lock' => [
265+
'payload' => 'semaphore'
266+
],
267+
],
268+
]);
269+
270+
$this->assertEquals(
271+
[
272+
'enabled' => true,
273+
'resources' => [
274+
'payload' => ['semaphore']
275+
],
276+
],
277+
$config['lock']
278+
);
279+
}
280+
253281
public function testItShowANiceMessageIfTwoMessengerBusesAreConfiguredButNoDefaultBus()
254282
{
255283
$expectedMessage = 'You must specify the "default_bus" if you define more than one bus.';

0 commit comments

Comments
 (0)