diff --git a/src/Symfony/Component/Security/Core/Exception/CustomUserMessageAuthenticationException.php b/src/Symfony/Component/Security/Core/Exception/CustomUserMessageAuthenticationException.php index 1faf6d9d5341f..ed9fb1bd339b9 100644 --- a/src/Symfony/Component/Security/Core/Exception/CustomUserMessageAuthenticationException.php +++ b/src/Symfony/Component/Security/Core/Exception/CustomUserMessageAuthenticationException.php @@ -60,7 +60,7 @@ public function getMessageData() */ public function serialize() { - return serialize([parent::serialize(true), $this->messageKey, $this->messageData]); + $serialized = [parent::serialize(true), $this->messageKey, $this->messageData]; return $this->doSerialize($serialized, \func_num_args() ? \func_get_arg(0) : null); } diff --git a/src/Symfony/Component/Security/Core/Tests/Exception/CustomUserMessageAuthenticationExceptionTest.php b/src/Symfony/Component/Security/Core/Tests/Exception/CustomUserMessageAuthenticationExceptionTest.php index d69d3bffcb54a..32c76a452f702 100644 --- a/src/Symfony/Component/Security/Core/Tests/Exception/CustomUserMessageAuthenticationExceptionTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Exception/CustomUserMessageAuthenticationExceptionTest.php @@ -15,6 +15,21 @@ use Symfony\Component\Security\Core\Authentication\Token\AnonymousToken; use Symfony\Component\Security\Core\Exception\CustomUserMessageAuthenticationException; +class ChildCustomUserMessageAuthenticationException extends CustomUserMessageAuthenticationException +{ + public function serialize() + { + return serialize([$this->childMember, parent::serialize()]); + } + + public function unserialize($str) + { + list($this->childMember, $parentData) = unserialize($str); + + parent::unserialize($parentData); + } +} + class CustomUserMessageAuthenticationExceptionTest extends TestCase { public function testConstructWithSAfeMessage() @@ -39,4 +54,18 @@ public function testSharedSerializedData() $this->assertEquals($token, $processed->getMessageData()['token']); $this->assertSame($processed->getToken(), $processed->getMessageData()['token']); } + + public function testSharedSerializedDataFromChild() + { + $token = new AnonymousToken('foo', 'bar'); + + $exception = new ChildCustomUserMessageAuthenticationException(); + $exception->childMember = $token; + $exception->setToken($token); + + $processed = unserialize(serialize($exception)); + $this->assertEquals($token, $processed->childMember); + $this->assertEquals($token, $processed->getToken()); + $this->assertSame($processed->getToken(), $processed->childMember); + } } 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