Closed
Description
Symfony version(s) affected: 4.4
Description
Messenger config options
array merged wrong. Values inside specific environment config of options
array are merged to common config with numbers as keys.
How to reproduce
- Create
messenger.yaml
inconfig/packages/
with following contents:
framework:
messenger:
transports:
async: "%env(MESSENGER_TRANSPORT_DSN)%"
options:
auto_setup: false
- Then, create another, for example, for the test environment
config/packages/test/
and add options there:
framework:
messenger:
transports:
async: "%env(MESSENGER_TRANSPORT_DSN)%"
options:
wait_time: 60
- Run console debug:config:
console debug:config framework
#...
messenger:
transports:
async:
dsn: '%env(MESSENGER_TRANSPORT_DSN)%'
options:
auto_setup: true
#...
- Run console debug:config for test-environment:
APP_ENV=test console debug:config framework
Output for test-environment:
#...
messenger:
transports:
async:
dsn: '%env(MESSENGER_TRANSPORT_DSN)%'
options:
auto_setup: true
0: 60
#...
Additional context
That's happened because in ConfigTree options are defined as arrayNode
and has a prototype('variable')
. So for combining config together PrototypedArrayNode::mergeValues()
would be called. And there is an issue. For those PrototypedArrayNode
that have not $keyAttribute
$rightSide
values added without keys:
foreach ($rightSide as $k => $v) {
// prototype, and key is irrelevant, append the element
if (null === $this->keyAttribute) {
$leftSide[] = $v;
continue;
}
Possible soultion
So the solution is to add useAttributeAsKey
inside ConfigTree for arrayNode('options'). PR will be submitted soon