Skip to content

[Messenger] remove AllowNoHandlerMiddleware in favor of a constructor argument on HandleMessageMiddleware #28945

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

Merged
merged 1 commit into from
Oct 25, 2018

Conversation

nicolas-grekas
Copy link
Member

@nicolas-grekas nicolas-grekas commented Oct 22, 2018

Q A
Branch? 4.2
Bug fix? no
New feature? no
BC breaks? yes
Deprecations? no
Tests pass? yes
Fixed tickets -
License MIT
Doc PR -

AllowNoHandlerMiddleware adds a frame in the call stack but its concern should be handled by HandleMessageMiddleware to me, and HandlerLocatorInterface::getHandler() should not care about whether it's an error or not to not have a middleware (this makes it on par with SenderLocator in this regard.)

@nicolas-grekas nicolas-grekas added this to the 4.2 milestone Oct 22, 2018
@nicolas-grekas nicolas-grekas force-pushed the messenger-allow-no-handler branch from fa653b8 to d3005e8 Compare October 22, 2018 07:23
@nicolas-grekas nicolas-grekas requested a review from sroze as a code owner October 22, 2018 07:23
@nicolas-grekas nicolas-grekas force-pushed the messenger-allow-no-handler branch 2 times, most recently from b8407df to 5c6b0b6 Compare October 22, 2018 13:11
return array($middleware);
->always()
->then(function ($middleware) {
return \is_string($middleware) || !\is_int(key($middleware)) ? array($middleware) : $middleware;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(this borrows from Processor::normalizeConfig() and fixes a bug actually, same as what fixXmlConfig() does, but when no plural form exists)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we put \is_string($middleware) || !\is_int(key($middleware)) inside ifTrue() instead of using always()? Would be consistent with the rest of the nodes I guess.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makes sense, updated

@nicolas-grekas nicolas-grekas force-pushed the messenger-allow-no-handler branch from 5c6b0b6 to 3cab9b2 Compare October 22, 2018 17:26
$handler($envelope->getMessage());
$next($envelope);
} elseif (!$this->allowNoHandlers) {
throw new NoHandlerForMessageException(sprintf('No handler for message "%s".', \get_class($envelope->getMessage())));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will become $envelope->getDispatchKey() ?? \get_class($envelope->getMessage() right

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct, one PR or the other will need a rebase once merged.

@nicolas-grekas nicolas-grekas force-pushed the messenger-allow-no-handler branch from 3cab9b2 to e447a5f Compare October 24, 2018 11:11
@sroze
Copy link
Contributor

sroze commented Oct 25, 2018

For the records, now, to allow no handlers on a given bus, here is the following configuration:

framework:
  messenger:
    buses:
      events:
        default_middleware: allow_no_handlers

@sroze
Copy link
Contributor

sroze commented Oct 25, 2018

Thank you @nicolas-grekas.

@sroze sroze merged commit aedb281 into symfony:master Oct 25, 2018
sroze added a commit that referenced this pull request Oct 25, 2018
…f a constructor argument on HandleMessageMiddleware (nicolas-grekas)

This PR was merged into the 4.2-dev branch.

Discussion
----------

[Messenger] remove AllowNoHandlerMiddleware in favor of a constructor argument on HandleMessageMiddleware

| Q             | A
| ------------- | ---
| Branch?       | 4.2
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | yes
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

`AllowNoHandlerMiddleware` adds a frame in the call stack but its concern should be handled by `HandleMessageMiddleware` to me, and `HandlerLocatorInterface::getHandler()` should not care about whether it's an error or not to not have a middleware (this makes it on par with `SenderLocator` in this regard.)

Commits
-------

aedb281 [Messenger] remove AllowNoHandlerMiddleware in favor of a constructor argument on HandleMessageMiddleware
@nicolas-grekas nicolas-grekas deleted the messenger-allow-no-handler branch October 25, 2018 09:41
nicolas-grekas added a commit that referenced this pull request Oct 25, 2018
…is empty, it will be `null` (sroze)

This PR was merged into the 4.2-dev branch.

Discussion
----------

[Messenger] If `framework.messenger.buses.X.middleware` is empty, it will be `null`

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #28945
| License       | MIT
| Doc PR        | ø

Otherwise, it would fail with the following configuration:
```yaml
framework:
    messenger:
        buses:
            events_bus:
                middleware:
#                    - 'some_commented_middleware'
```

Commits
-------

91a70fc If `framework.messenger.buses.X.middleware` is empty, it will be `null`
This was referenced Nov 3, 2018
javiereguiluz added a commit to symfony/symfony-docs that referenced this pull request Dec 28, 2018
This PR was merged into the 4.2 branch.

Discussion
----------

[Messenger] Fix allow_no_handlers for 4.2

Fixes #10689 (comment)

Ref: symfony/symfony#28945

Commits
-------

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

Successfully merging this pull request may close these issues.

6 participants