-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Webhook] SerializerInterface is not actually needed #57567
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
Comments
However, I don't see any usages of |
|
It's a dev dependency, which is not installed in my case as expected. Messenger uses PhpSerializer by default if you don't specify custom serializer which doesn't need Anyway you missed my point, you don't need the serializer component to turn an public function __construct(
private readonly ?SerializerInterface $serializer = null,
) {
}
//
$body = $this->serializer?->serialize($event->getPayload(), 'json') ?? \json_encode($event->getPayload()); |
Sorry, I missed it's the dev dependency block. You're right. Since it's optional, SerializerInterface should be nullable and |
see #57881 |
…alizer component (xabbuh) This PR was merged into the 7.2 branch. Discussion ---------- [Webhook] decouple the Webhook component from the Serializer component | Q | A | ------------- | --- | Branch? | 7.2 | Bug fix? | no | New feature? | yes | Deprecations? | no | Issues | Fix #57567 | License | MIT Commits ------- ef32a22 decouple the Webhook component from the Serializer component
Uh oh!
There was an error while loading. Please reload this page.
Symfony version(s) affected
7.x
Description
A quick search shows that this line is the only place where the serializer is used in the webhook component.
https://github.com/symfony/webhook/blob/67762b59de4b9e3c6918c44a345f59030923b82d/Server/JsonBodyConfigurator.php#L24
To be fair I don't think this is a bug, however serializer is not really needed to encode the event payload since it's always
array
,json_encode
is fine.How to reproduce
Create a new
SendWebhookMessage
then dispatch it without installing the serializerPossible Solution
Remove
SerializerInterface
and replacewith
Additional Context
No response
The text was updated successfully, but these errors were encountered: