8000 [Messenger] When using Messenger's Serializer for JSON: some stamps fail (e.g. TransportNamesStamp) · Issue #49574 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Messenger] When using Messenger's Serializer for JSON: some stamps fail (e.g. TransportNamesStamp) #49574

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

Closed
StephanMeijer opened this issue Mar 1, 2023 · 1 comment

Comments

@StephanMeijer
Copy link

Symfony version(s) affected

6.2, 6.3

Description

When using Symfony\Component\Messenger\Transport\Serialization\Serializer, serializing and then deserializing some stamps, such as Symfony\Component\Messenger\Stamp\TransportNamesStamp fail due to the name of the getter not matching the name in the constructor.

How to reproduce

Use the serializer Symfony\Component\Messenger\Transport\Serialization\Serializer to serialize and deserialize this Stamp.

Possible Solution

Rename the variable name $transports to $transportNames in the constructor.

Additional Context

I will put out a PR myself.

@tsantos84
Copy link
Contributor

Hi. For record purposes, I also was affected by this issue. Thanks for the PR.

nicolas-grekas added a commit that referenced this issue Mar 6, 2023
…ksaun)

This PR was merged into the 6.2 branch.

Discussion
----------

[Messenger] Fix `TransportNamesStamp` deserialization

| Q             | A
| ------------- | ---
| Branch?       | 6.2
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | #49574, #31490 (comment)
| License       | MIT
| Doc PR        | n/a

Currently, when ones use `TransportNameStamp` the following exception can occur if they don't use native PHP serialization:

```
In Serializer.php line 125:

  [Symfony\Component\Messenger\Exception\MessageDecodingFailedException]
  Could not decode stamp: Cannot create an instance of "Symfony\Component\Messenger\Stamp\TransportNamesStamp" from serialized data because its constructor requires parameter "transports" to be present.

In AbstractNormalizer.php line 384:

  [Symfony\Component\Serializer\Exception\MissingConstructorArgumentsException]
  Cannot create an instance of "Symfony\Component\Messenger\Stamp\TransportNamesStamp" from serialized data because its constructor requires parameter "transports" to be present.

```

This PR renames `TransportNamesStamp` constructor argument in order to match the accessor method (`getTransportNames`) so that deserialization works when using the Serializer.

I know this is technically a (small) BC break but Symfony's BC does not cover named arguments if I remember correctly.

Commits
-------

2c7eee0 [Messenger] Fix TransportNamesStamp deserialization
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants
0