Skip to content

Commit

Permalink
bug #47455 [Mime] Fix TextPart broken after being serialized (fabpot)
Browse files Browse the repository at this point in the history
This PR was merged into the 5.4 branch.

Discussion
----------

[Mime] Fix TextPart broken after being serialized

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

When serializing a TextPart, it's broken as we change the body to a string but we don't reset the seekable property (this property was introduced in 5.4).

Commits
-------

a1a1609 [Mime] Fix TextPart broken after being serialized
  • Loading branch information
fabpot committed Sep 2, 2022
2 parents c61dfca + a1a1609 commit 72a3ad5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/Symfony/Component/Mime/Part/TextPart.php
Expand Up @@ -197,6 +197,7 @@ public function __sleep()
// convert resources to strings for serialization
if (null !== $this->seekable) {
$this->body = $this->getBody();
$this->seekable = null;
}

$this->_headers = $this->getHeaders();
Expand Down
4 changes: 3 additions & 1 deletion src/Symfony/Component/Mime/Tests/Part/TextPartTest.php
Expand Up @@ -87,6 +87,8 @@ public function testSerialize()
$p = new TextPart($r);
$p->getHeaders()->addTextHeader('foo', 'bar');
$expected = clone $p;
$this->assertEquals($expected->toString(), unserialize(serialize($p))->toString());
$n = unserialize(serialize($p));
$this->assertEquals($expected->toString(), $p->toString());
$this->assertEquals($expected->toString(), $n->toString());
}
}

0 comments on commit 72a3ad5

Please sign in to comment.