Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
Description
Symfony version(s) affected: master (4.3)
Description
When creating a handler that implementsMessageSubscriberInterface, which passes custom options about the handler (e.g.from_transport from#30958), if the user changes those options, they are not visible in the app. The problem is that this input is used to create an internal service (https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Messenger/DependencyInjection/MessengerPass.php#L168), but the files these options were sourced from (the handler itself) is not added as a container resource.
How to reproduce
namespaceApp\MessageHandler;useApp\Message\SendEmail;useSymfony\Component\Messenger\Handler\MessageSubscriberInterface;class SendEmailHandlerimplements MessageSubscriberInterface{publicfunction__invoke(SendEmail$email) {// }publicstaticfunctiongetHandledMessages():iterable {yield SendEmail::class => ['from_transport' =>'async', ]; }}
Completely clear the cache. You can see that this handler is only called when coming from someasync transport. Now, change to some other transport name and try again. It willstill try to consume only from the original,async transport.
Possible Solution
If the config comes from the handler (i.e. if it implementsMessageSubscriberInterface), it should be added as a resource. Doesn't this also affect normalMessageHandlerInterface handlers - if you changed the type-hint to__invoke(), would that cause a container rebuild?