Skip to content
Permalink
Browse files

bug #32380 [Messenger] fix broken key normalization (Tobion)

This PR was merged into the 4.3 branch.

Discussion
----------

[Messenger] fix broken key normalization

| Q             | A
| ------------- | ---
| Branch?       | 4.3
| Bug fix?      | yes
| New feature?  | no <!-- please update src/**/CHANGELOG.md files -->
| BC breaks?    | no     <!-- see https://symfony.com/bc -->
| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tests pass?   | yes    <!-- please add some, will be required by reviewers -->
| Fixed tickets |
| License       | MIT
| Doc PR        |

Disable broken key normalization in messenger config.

If you tried to use `-` in a transport/bus it didn't work and you get a cryptic error (#31613)

```
framework:
    messenger:
        transports:
            my-bus: '...'
        routing:
            Acme\MyMessage: my-bus
```

The default behavior of normalizing keys is really annoying and a waste of time in most cases. I've measured `\Symfony\Component\Config\Definition\ArrayNode::preNormalize` in a project and it takes 4 ms.
As an idea, we could disabling normalizing keys automatically when you call `useAttributeAsKey` because the value is then user-provided and shouldn't be modified (in contrast to children properties of an arrayNode which should get normalized for xml support).

Commits
-------

9931b3e [Messenger] fix broken key normalization
  • Loading branch information...
fabpot committed Jul 5, 2019
2 parents 511fc93 + 9931b3e commit c799fc803dae5b9413140f72315a5b4d7ebf5dc7
Showing with 3 additions and 0 deletions.
  1. +3 −0 src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php
@@ -1114,6 +1114,7 @@ private function addMessengerSection(ArrayNodeDefinition $rootNode)
->end()
->children()
->arrayNode('routing')
->normalizeKeys(false)
->useAttributeAsKey('message_class')
->beforeNormalization()
->always()
@@ -1173,6 +1174,7 @@ function ($a) {
->end()
->end()
->arrayNode('transports')
->normalizeKeys(false)
->useAttributeAsKey('name')
->arrayPrototype()
->beforeNormalization()
@@ -1220,6 +1222,7 @@ function ($a) {
->scalarNode('default_bus')->defaultNull()->end()
->arrayNode('buses')
->defaultValue(['messenger.bus.default' => ['default_middleware' => true, 'middleware' => []]])
->normalizeKeys(false)
->useAttributeAsKey('name')
->arrayPrototype()
->addDefaultsIfNotSet()

0 comments on commit c799fc8

Please sign in to comment.
You can’t perform that action at this time.