From c28de1302fc0dd897d43620581b49c3969f8bb87 Mon Sep 17 00:00:00 2001 From: Matthias Krauser Date: Fri, 24 Nov 2023 15:50:44 +0100 Subject: [PATCH] [Mime] Add TemplatedEmail::$locale to the serialized props (fixes #52718) --- src/Symfony/Bridge/Twig/Mime/TemplatedEmail.php | 4 ++-- src/Symfony/Bridge/Twig/Tests/Mime/TemplatedEmailTest.php | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Bridge/Twig/Mime/TemplatedEmail.php b/src/Symfony/Bridge/Twig/Mime/TemplatedEmail.php index e5c990f3ba733..23bfcb5c5a0d1 100644 --- a/src/Symfony/Bridge/Twig/Mime/TemplatedEmail.php +++ b/src/Symfony/Bridge/Twig/Mime/TemplatedEmail.php @@ -100,7 +100,7 @@ public function markAsRendered(): void */ public function __serialize(): array { - return [$this->htmlTemplate, $this->textTemplate, $this->context, parent::__serialize()]; + return [$this->htmlTemplate, $this->textTemplate, $this->context, $this->locale, parent::__serialize()]; } /** @@ -108,7 +108,7 @@ public function __serialize(): array */ public function __unserialize(array $data): void { - [$this->htmlTemplate, $this->textTemplate, $this->context, $parentData] = $data; + [$this->htmlTemplate, $this->textTemplate, $this->context, $this->locale, $parentData] = $data; parent::__unserialize($parentData); } diff --git a/src/Symfony/Bridge/Twig/Tests/Mime/TemplatedEmailTest.php b/src/Symfony/Bridge/Twig/Tests/Mime/TemplatedEmailTest.php index f796c7a05db7e..81f0edb6870ea 100644 --- a/src/Symfony/Bridge/Twig/Tests/Mime/TemplatedEmailTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Mime/TemplatedEmailTest.php @@ -43,12 +43,14 @@ public function testSerialize() ->textTemplate('text.txt.twig') ->htmlTemplate('text.html.twig') ->context($context = ['a' => 'b']) + ->locale($locale = 'fr_FR') ; $email = unserialize(serialize($email)); $this->assertEquals('text.txt.twig', $email->getTextTemplate()); $this->assertEquals('text.html.twig', $email->getHtmlTemplate()); $this->assertEquals($context, $email->getContext()); + $this->assertEquals($locale, $email->getLocale()); } public function testSymfonySerialize()