Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a2eabcc

Browse files
committed
[Messenger] Messenger options were merged with numbers as keys.
Allow named keys on right side to be merged without restriction on key-name (when useAttributeAsKey($keyName) is used).
1 parent 6865689 commit a2eabcc

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1267,7 +1267,6 @@ function ($a) {
12671267
->scalarNode('dsn')->end()
12681268
->scalarNode('serializer')->defaultNull()->info('Service id of a custom serializer to use.')->end()
12691269
->arrayNode('options')
1270-
->useAttributeAsKey('option')
12711270
->normalizeKeys(false)
12721271
->defaultValue([])
12731272
->prototype('variable')

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,13 @@ public function testMessengerMergeConfigsTransportOptions()
303303
'options' => [
304304
'wait_time' => 20,
305305
'option' => 'bar',
306+
'queue' => [
307+
'name' => 'Queue',
308+
'option' => 'foo',
309+
'queue_options' => [
310+
'option' => 'foo',
311+
],
312+
],
306313
],
307314
],
308315
],
@@ -315,6 +322,13 @@ public function testMessengerMergeConfigsTransportOptions()
315322
'auto_setup' => true,
316323
'option' => 'bar',
317324
'wait_time' => 20,
325+
'queue' => [
326+
'name' => 'Queue',
327+
'option' => 'foo',
328+
'queue_options' => [
329+
'option' => 'foo',
330+
],
331+
],
318332
],
319333
$config['messenger']['transports']['async']['options']
320334
);

src/Symfony/Component/Config/Definition/PrototypedArrayNode.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -304,9 +304,10 @@ protected function mergeValues($leftSide, $rightSide)
304304
return $rightSide;
305305
}
306306

307+
$isAssoc = array_keys($rightSide) !== range(0, \count($rightSide) - 1);
307308
foreach ($rightSide as $k => $v) {
308-
// prototype, and key is irrelevant, append the element
309-
if (null === $this->keyAttribute) {
309+
// prototype, and key is irrelevant there are no named keys, append the element
310+
if (null === $this->keyAttribute && !$isAssoc) {
310311
$leftSide[] = $v;
311312
continue;
312313
}

0 commit comments

Comments
 (0)