-
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
Description
Symfony version(s) affected
5.2 and above
Description
Hi,
I've been experiencing with Symfony/Messenger for a bit and I noticed that when subscribing to WorkerMessageReceivedEvent the envelope was not mutable due to the fact that the parent class does not support setEnvelope.
You can see the changelog here stating that this method was added here.
5.2.0
---
Added WorkerMessageReceivedEvent::setEnvelope() and made event mutable
When looking at the commit responsible for introducing this feature, you can see the work done on the worker to get the envelope back after the dispatch and the added addStamp method operating on the envelope itself but no code allowing for a redefinition of the aforementioned envelope.
I am betting on a mistake as we are indeed making the envelope mutable with addStamp and either the setter was planned and got removed but the changelog message was not changed?
How to reproduce
Install any version of symfony/Messenger after 5.2
$envelope = new \Symfony\Component\Messenger\Envelope::wrap(new \stdClass());
$event = new \Symfony\Component\Messenger\Event\WorkerMessageReceivedEvent($envelope, 'myReceiver');
$event->setEnvelope(); // This method does not existPossible Solution
Implement setEnvelope in either WorkerMessageReceivedEvent or the parent class.
Additional Context
No response