Skip to content

Commit 61ae0ff

Browse files
committed
Merge branch '2.3' into 2.4
* 2.3: (31 commits) Fix parent serialization of user object [DependencyInjection] fixed typo add memcache, memcached, and mongodb extensions to run skipped tests [DependencyInjection] Fixed support for backslashes in service ids. fix #9356 [Security] Logger should manipulate the user reloaded from provider [BrowserKit] fixes #8311 CookieJar is totally ignorant of RFC 6265 edge cases [HttpFoundation] fixed constants that do exist in 2.3 (only in 2.4) fix 5528 let ArrayNode::normalizeValue respect order of value array provided fix #7243 allow 0 as arraynode name Fixed issue in BaseDateTimeTransformer when invalid timezone cause Transformation filed exception (closes #9403). BinaryFileResponse should also return 416 or 200 on some range-requets Do normalization on tag options bumped Symfony version to 2.3.9 updated VERSION for 2.3.8 update CONTRIBUTORS for 2.3.8 updated CHANGELOG for 2.3.8 [Filesystem] Changed the mode for a target file in copy() to be write only. [Console] fixed CS fixed TableHelper when cell value has new line Improved and fixed grammar mistakes. Added pluralized messages ... Conflicts: src/Symfony/Component/BrowserKit/Cookie.php src/Symfony/Component/HttpKernel/Kernel.php src/Symfony/Component/Routing/Matcher/UrlMatcher.php
2 parents e578003 + 29006c2 commit 61ae0ff

File tree

2 files changed

+49
-1
lines changed

2 files changed

+49
-1
lines changed

Authentication/Token/AbstractToken.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,14 @@ public function eraseCredentials()
142142
*/
143143
public function serialize()
144144
{
145-
return serialize(array($this->user, $this->authenticated, $this->roles, $this->attributes));
145+
return serialize(
146+
array(
147+
is_object($this->user) ? clone $this->user : $this->user,
148+
$this->authenticated,
149+
$this->roles,
150+
$this->attributes
151+
)
152+
);
146153
}
147154

148155
/**

Tests/Authentication/Token/AbstractTokenTest.php

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111

1212
namespace Symfony\Component\Security\Core\Tests\Authentication\Token;
1313

14+
use Symfony\Component\Security\Core\Authentication\Token\AbstractToken;
1415
use Symfony\Component\Security\Core\Role\Role;
16+
use Symfony\Component\Security\Core\Role\SwitchUserRole;
1517

1618
class TestUser
1719
{
@@ -28,6 +30,31 @@ public function __toString()
2830
}
2931
}
3032

33+
class ConcreteToken extends AbstractToken
34+
{
35+
private $credentials = 'credentials_value';
36+
37+
public function __construct($user, array $roles = array())
38+
{
39+
parent::__construct($roles);
40+
41+
$this->setUser($user);
42+
}
43+
44+
public function serialize()
45+
{
46+
return serialize(array($this->credentials, parent::serialize()));
47+
}
48+
49+
public function unserialize($serialized)
50+
{
51+
list($this->credentials, $parentStr) = unserialize($serialized);
52+
parent::unserialize($parentStr);
53+
}
54+
55+
public function getCredentials() {}
56+
}
57+
3158
class AbstractTokenTest extends \PHPUnit_Framework_TestCase
3259
{
3360
public function testGetUsername()
@@ -71,6 +98,20 @@ public function testSerialize()
7198
$this->assertEquals($token->getAttributes(), $uToken->getAttributes());
7299
}
73100

101+
public function testSerializeParent()
102+
{
103+
$user = new TestUser('fabien');
104+
$token = new ConcreteToken($user, array('ROLE_FOO'));
105+
106+
$parentToken = new ConcreteToken($user, array(new SwitchUserRole('ROLE_PREVIOUS', $token)));
107+
$uToken = unserialize(serialize($parentToken));
108+
109+
$this->assertEquals(
110+
current($parentToken->getRoles())->getSource()->getUser(),
111+
current($uToken->getRoles())->getSource()->getUser()
112+
);
113+
}
114+
74115
/**
75116
* @covers Symfony\Component\Security\Core\Authentication\Token\AbstractToken::__construct
76117
*/

0 commit comments

Comments
 (0)