8000 minor #29027 [Messenger] Add some UPGRADE entries regarding 4.2 BC br… · symfony/symfony@8539649 · GitHub
[go: up one dir, main page]

Skip to content

Commit 8539649

Browse files
committed
minor #29027 [Messenger] Add some UPGRADE entries regarding 4.2 BC breaks (ogizanagi)
This PR was merged into the 4.2-dev branch. Discussion ---------- [Messenger] Add some UPGRADE entries regarding 4.2 BC breaks | Q | A | ------------- | --- | Branch? | 4.2 <!-- see below --> | Bug fix? | no | New feature? | no <!-- don't forget to update src/**/CHANGELOG.md files --> | BC breaks? | no <!-- see https://symfony.com/bc --> | Deprecations? | no <!-- don't forget to update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Tests pass? | yes <!-- please add some, will be required by reviewers --> | Fixed tickets | N/A <!-- #-prefixed issue number(s), if any --> | License | MIT | Doc PR | N/A Just highlighting most relevant changes for users and their upgrade paths. For exhaustivity, you'll still have to read the Messenger CHANGELOG file. Commits ------- c9786c2 [Messenger] Add some UPGRADE entries regarding 4.2 BC breaks
2 parents 0970b09 + c9786c2 commit 8539649

File tree

1 file changed

+82
-2
lines changed

1 file changed

+82
-2
lines changed

UPGRADE-4.2.md

Lines changed: 82 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,28 @@ HttpKernel
125125
FrameworkBundle
126126
---------------
127127

128+
* The `allow_no_handler` middleware has been removed. Use `framework.messenger.buses.[bus_id].default_middleware` instead:
129+
130+
Before:
131+
```yaml
132+
framework:
133+
messenger:
134+
buses:
135+
messenger.bus.events:
136+
middleware:
137+
- allow_no_handler
138+
```
139+
140+
After:
141+
```yaml
142+
framework:
143+
messenger:
144+
buses:
145+
messenger.bus.events:
146+
default_middleware: allow_no_handlers
147+
```
148+
149+
* The `messenger:consume-messages` command expects a mandatory `--bus` option value if you have more than one bus configured.
128150
* The `framework.router.utf8` configuration option has been added. If your app's charset
129151
is UTF-8 (see kernel's `getCharset()` method), it is recommended to set it to `true`:
130152
this will generate 404s for non-UTF-8 URLs, which are incompatible with you app anyway,
@@ -161,8 +183,66 @@ FrameworkBundle
161183
Messenger
162184
---------
163185

164-
* `EnvelopeItemInterface` doesn't extend `Serializable` anymore
165-
* The `handle` method of the `Symfony\Component\Messenger\Middleware\ValidationMiddleware` and `Symfony\Component\Messenger\Asynchronous\Middleware\SendMessageMiddleware` middlewares now requires an `Envelope` object to be given (because they implement the `EnvelopeAwareInterface`). When using these middleware with the provided `MessageBus`, you will not have to do anything. If you use the middlewares any other way, you can use `Envelope::wrap($message)` to create an envelope for your message.
186+
* The `MiddlewareInterface::handle()` and `SenderInterface::send()` methods must now return an `Envelope` instance.
187+
* The return value of handlers is ignored. If you used to return a value, e.g in query bus handlers, you can either:
188+
- make your `Query` mutable to allow setting & getting a result:
189+
```php
190+
// When dispatching:
191+
$bus->dispatch($query = new Query());
192+
$result = $query->getResult();
193+
194+
// In your handler:
195+
$query->setResult($yourResult);
196+
```
197+
- define a callable on your `Query` to be called in your handler:
198+
```php
199+
// When dispatching:
200+
$bus->dispatch(new Query([$this, 'onResult']));
201+
202+
// In your handler:
203+
$query->executeCallback($yourResult);
204+
```
205+
206+
* The `EnvelopeAwareInterface` was removed and the `MiddlewareInterface::handle()` method now requires an `Envelope` object
207+
as first argument. When using built-in middleware with the provided `MessageBus`, you will not have to do anything.
208+
If you use your own `MessageBusInterface` implementation, you must wrap the message in an `Envelope` before passing it to middleware.
209+
If you created your own middleware, you must change the signature to always expect an `Envelope`.
210+
* The `MiddlewareInterface::handle()` second argument (`callable $next`) has changed in favor of a `StackInterface` instance.
211+
When using built-in middleware with the provided `MessageBus`, you will not have to do anything.
212+
If you use your own `MessageBusInterface` implementation, you can use the `StackMiddleware` implementation.
213+
If you created your own middleware, you must change the signature to always expect an `StackInterface` instance
214+
and call `$stack->next()->handle($envelope, $stack)` instead of `$next` to call the next middleware:
215+
216+
Before:
217+
```php
218+
public function handle($message, callable $next): Envelope
219+
{
220+
// do something before
221+
$message = $next($message);
222+
// do something after
223+
224+
return $message;
225+
}
226+
```
227+
228+
After:
229+
```php
230+
public function handle(Envelope $envelope, StackInterface $stack): Envelope
231+
{
232+
// do something before
233+
$envelope = $stack->next()->handle($envelope, $stack);
234+
// do something after
235+
236+
return $envelope;
237+
}
238+
```
239+
* `StampInterface` replaces `EnvelopeItemInterface` and doesn't extend `Serializable` anymore.
240+
Built-in `ReceivedMessage`, `ValidationConfiguration` and `SerializerConfiguration` were renamed
241+
respectively `ReceivedStamp`, `ValidationStamp`, `SerializerStamp` and moved to the `Stamp` namespace.
242+
* `AllowNoHandlerMiddleware` has been removed in favor of a new constructor argument on `HandleMessageMiddleware`
243+
* The `ConsumeMessagesCommand` class now takes an instance of `Psr\Container\ContainerInterface`
244+
as first constructor argument, i.e a message bus locator. The CLI command now expects a mandatory
245+
`--bus` option value if there is more than one bus in the locator.
166246
* `MessageSubscriberInterface::getHandledMessages()` return value has changed. The value of an array item
167247
needs to be an associative array or the method name.
168248

0 commit comments

Comments
 (0)
0