Skip to content
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());
}
}