From 6bb2d67cf12f82c76ae0e7bf02598e8a38e85fff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Deruss=C3=A9?= Date: Sat, 2 Jan 2021 23:17:56 +0100 Subject: [PATCH] Fix config merging in lock --- .../DependencyInjection/Configuration.php | 3 ++ .../DependencyInjection/ConfigurationTest.php | 28 +++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php index d23bdbc480..58148b18ca 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php @@ -1122,6 +1122,8 @@ class Configuration implements ConfigurationInterface ->fixXmlConfig('resource') ->children() ->arrayNode('resources') + ->normalizeKeys(false) + ->useAttributeAsKey('name') ->requiresAtLeastOneElement() ->defaultValue(['default' => [class_exists(SemaphoreStore::class) && SemaphoreStore::isSupported() ? 'semaphore' : 'flock']]) ->beforeNormalization() @@ -1144,6 +1146,7 @@ class Configuration implements ConfigurationInterface }) ->end() ->prototype('array') + ->performNoDeepMerging() ->beforeNormalization()->ifString()->then(function ($v) { return [$v]; })->end() ->prototype('scalar')->end() ->end() diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php index aff4e5ea41..e19ed2964c 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php @@ -250,6 +250,34 @@ class ConfigurationTest extends TestCase yield [['enabled' => false, 'resource' => [['name' => 'foo', 'value' => 'flock'], ['name' => 'foo', 'value' => 'semaphore'], ['name' => 'bar', 'value' => 'semaphore']]], ['enabled' => false, 'resources' => ['foo' => ['flock', 'semaphore'], 'bar' => ['semaphore']]]]; } + public function testLockMergeConfigs() + { + $processor = new Processor(); + $configuration = new Configuration(true); + $config = $processor->processConfiguration($configuration, [ + [ + 'lock' => [ + 'payload' => 'flock', + ], + ], + [ + 'lock' => [ + 'payload' => 'semaphore' + ], + ], + ]); + + $this->assertEquals( + [ + 'enabled' => true, + 'resources' => [ + 'payload' => ['semaphore'] + ], + ], + $config['lock'] + ); + } + public function testItShowANiceMessageIfTwoMessengerBusesAreConfiguredButNoDefaultBus() { $expectedMessage = 'You must specify the "default_bus" if you define more than one bus.';