8000 [Mime] Fix serialization of RawMessage by gilbertsoft · Pull Request #38433 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Mime] Fix serialization of RawMessage #38433

New iss 8000 ue

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
wants to merge 3 commits into from
Closed

[Mime] Fix serialization of RawMessage #38433

wants to merge 3 commits into from

Conversation

gilbertsoft
Copy link
Contributor
@gilbertsoft gilbertsoft commented Oct 6, 2020
Q A
Branch? 4.4
Bug fix? yes
New feature? no
Deprecations? no
Tickets Fix #38430, Related #33394
License MIT
Doc PR -

The serialization of RawMessage is currently broken if using a generator for message like done by Symfony\Component\Mailer\SentMessage see

$this->raw = new RawMessage($message->toIterable());

This patch converts the message to a string so further serialization can be done.

This patch probably also solves #33394.

@gilbertsoft gilbertsoft changed the title Fix serialization of RawMessage [Mime] Fix serialization of RawMessage Oct 6, 2020
@gilbertsoft gilbertsoft marked this pull request as ready for review October 6, 2020 12:54

$message = new RawMessage(new \ArrayObject(['some', ' ', 'string']));
$message = new RawMessage($message->toIterable());
$this->assertEquals('some string', unserialize(serialize($message))->toString());
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line will throw Exception: Serialization of 'Generator' is not allowed without the fix above

@fabpot
Copy link
Member
fabpot commented Oct 6, 2020

Thank you @gilbertsoft.

fabpot added a commit that referenced this pull request Oct 6, 2020
This PR was squashed before being merged into the 4.4 branch.

Discussion
----------

[Mime] Fix serialization of RawMessage

| Q             | A
| ------------- | ---
| Branch?       | 4.4 <!-- see below -->
| Bug fix?      | yes
| New feature?  | no <!-- please update src/**/CHANGELOG.md files -->
| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tickets       | Fix #38430, Related #33394 <!-- prefix each issue number with "Fix #", no need to create an issue if none exist, explain below instead -->
| License       | MIT
| Doc PR        | - <!-- required for new features -->

The serialization of RawMessage is currently broken if using a generator for message like done by `Symfony\Component\Mailer\SentMessage` see https://github.com/symfony/symfony/blob/5f1c3a797247a6d54992384df00bb22741fc1c34/src/Symfony/Component/Mailer/SentMessage.php#L45
This patch converts the message to a string so further serialization can be done.

This patch probably also solves #33394.

<!--
Replace this notice by a short README for your feature/bugfix. This will help people
understand your PR and can be used as a start for the documentation.

Additionally (see https://symfony.com/releases):
 - Always add tests and ensure they pass.
 - Never break backward compatibility (see https://symfony.com/bc).
 - Bug fixes must be submitted against the lowest maintained branch where they apply
   (lowest branches are regularly merged to upper ones so they get the fixes too.)
 - Features and deprecations must be submitted against branch 5.x.
-->

Commits
-------

fd99eb2 [Mime] Fix serialization of RawMessage
@fabpot fabpot closed this Oct 6, 2020
@gilbertsoft gilbertsoft deleted the fix-rawmessage-serialization branch October 6, 2020 15:05
@xabbuh xabbuh added this to the 4.4 milestone Oct 7, 2020
@xabbuh xabbuh added the Mime label Oct 7, 2020
@fabpot fabpot mentioned this pull request Oct 14, 2020
This was referenced Oct 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
0