Skip to content

[Mime] Fix serialization of RawMessage #38433

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
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Symfony/Component/Mime/RawMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ final public function unserialize($serialized)

public function __serialize(): array
{
return [$this->message];
return [$this->toString()];
}

public function __unserialize(array $data): void
Expand Down
14 changes: 14 additions & 0 deletions src/Symfony/Component/Mime/Tests/RawMessageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,18 @@ public function testToString()
$this->assertEquals('some string', $message->toString());
$this->assertEquals('some string', implode('', iterator_to_array($message->toIterable())));
}

public function testSerialization()
{
$message = new RawMessage('string');
$this->assertEquals('string', unserialize(serialize($message))->toString());
// calling methods more than once work
$this->assertEquals('string', unserialize(serialize($message))->toString());

$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

// calling methods more than once work
$this->assertEquals('some string', unserialize(serialize($message))->toString());
}
}
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy