Skip to content

Commit 72a3ad5

Browse files
committed
bug #47455 [Mime] Fix TextPart broken after being serialized (fabpot)
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
2 parents c61dfca + a1a1609 commit 72a3ad5

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

src/Symfony/Component/Mime/Part/TextPart.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ public function __sleep()
197197
// convert resources to strings for serialization
198198
if (null !== $this->seekable) {
199199
$this->body = $this->getBody();
200+
$this->seekable = null;
200201
}
201202

202203
$this->_headers = $this->getHeaders();

src/Symfony/Component/Mime/Tests/Part/TextPartTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ public function testSerialize()
8787
$p = new TextPart($r);
8888
$p->getHeaders()->addTextHeader('foo', 'bar');
8989
$expected = clone $p;
90-
$this->assertEquals($expected->toString(), unserialize(serialize($p))->toString());
90+
$n = unserialize(serialize($p));
91+
$this->assertEquals($expected->toString(), $p->toString());
92+
$this->assertEquals($expected->toString(), $n->toString());
9193
}
9294
}

0 commit comments

Comments
 (0)