Skip to content
This repository was archived by the owner on May 31, 2024. It is now read-only.

Commit 3cc16df

Browse files
committed
Merge branch '2.6' into 2.7
* 2.6: Improve the config validation in TwigBundle [WebProfilerBundle][logger] added missing deprecation message. [Security][Acl] enforce string identifiers [BrowserKit] Fix bug when uri starts with http. bumped Symfony version to 2.3.31 updated VERSION for 2.3.30 updated CHANGELOG for 2.3.30 Php Inspections (EA Extended): - resolved possible PHP Fatal in \Symfony\Component\BrowserKit\Cookie::__toString -resolved implicit magic methods calls -resolved callable name case mismatches
2 parents c0dd66d + 8915e91 commit 3cc16df

File tree

3 files changed

+26
-4
lines changed

3 files changed

+26
-4
lines changed

Acl/Domain/ObjectIdentity.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ final class ObjectIdentity implements ObjectIdentityInterface
3636
*/
3737
public function __construct($identifier, $type)
3838
{
39-
if (empty($identifier)) {
39+
if ('' === $identifier) {
4040
throw new \InvalidArgumentException('$identifier cannot be empty.');
4141
}
4242
if (empty($type)) {
@@ -66,7 +66,7 @@ public static function fromDomainObject($domainObject)
6666
if ($domainObject instanceof DomainObjectInterface) {
6767
return new self($domainObject->getObjectIdentifier(), ClassUtils::getRealClass($domainObject));
6868
} elseif (method_exists($domainObject, 'getId')) {
69-
return new self($domainObject->getId(), ClassUtils::getRealClass($domainObject));
69+
return new self((string) $domainObject->getId(), ClassUtils::getRealClass($domainObject));
7070
}
7171
} catch (\InvalidArgumentException $invalid) {
7272
throw new InvalidDomainObjectException($invalid->getMessage(), 0, $invalid);

Acl/Tests/Domain/EntryTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function testSetAuditSuccess()
3636
$this->assertTrue($ace->isAuditSuccess());
3737
$ace->setAuditSuccess(false);
3838
$this->assertFalse($ace->isAuditSuccess());
39-
$ace->setAuditsuccess(true);
39+
$ace->setAuditSuccess(true);
4040
$this->assertTrue($ace->isAuditSuccess());
4141
}
4242

Acl/Tests/Domain/ObjectIdentityTest.php

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,26 @@ public function testFromDomainObjectWithProxy()
6464
$this->assertEquals('Symfony\Component\Security\Acl\Tests\Domain\TestDomainObject', $id->getType());
6565
}
6666

67+
public function testFromDomainObjectWithoutInterfaceEnforcesStringIdentifier()
68+
{
69+
$domainObject = new TestDomainObject();
70+
$domainObject->id = 1;
71+
$id = ObjectIdentity::fromDomainObject($domainObject);
72+
73+
$this->assertSame('1', $id->getIdentifier());
74+
$this->assertEquals('Symfony\Component\Security\Tests\Acl\Domain\TestDomainObject', $id->getType());
75+
}
76+
77+
public function testFromDomainObjectWithoutInterfaceAllowsZeroAsIdentifier()
78+
{
79+
$domainObject = new TestDomainObject();
80+
$domainObject->id = '0';
81+
$id = ObjectIdentity::fromDomainObject($domainObject);
82+
83+
$this->assertSame('0', $id->getIdentifier());
84+
$this->assertEquals('Symfony\Component\Security\Tests\Acl\Domain\TestDomainObject', $id->getType());
85+
}
86+
6787
/**
6888
* @dataProvider getCompareData
6989
*/
@@ -89,14 +109,16 @@ public function getCompareData()
89109

90110
class TestDomainObject
91111
{
112+
public $id = 'getId()';
113+
92114
public function getObjectIdentifier()
93115
{
94116
return 'getObjectIdentifier()';
95117
}
96118

97119
public function getId()
98120
{
99-
return 'getId()';
121+
return $this->id;
100122
}
101123
}
102124
}

0 commit comments

Comments
 (0)