8000 [Messenger] Messenger transport options are merged with numbers as keys · Issue #39846 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Messenger] Messenger transport options are merged with numbers as keys #39846

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
svitiashchuk opened this issue Jan 14, 2021 · 0 comments
Closed

Comments

@svitiashchuk
Copy link
Contributor

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

  1. Create messenger.yaml in config/packages/ with following contents:
framework:
    messenger:
        transports:
            async: "%env(MESSENGER_TRANSPORT_DSN)%"
            options:
                auto_setup: false
  1. 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
  1. Run console debug:config:
console debug:config framework
#...
messenger:
    transports:
        async:
            dsn: '%env(MESSENGER_TRANSPORT_DSN)%'
            options:
                auto_setup: true
#...
  1. 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants
0