Permalink
Browse files

Fix finding ACLs from ObjectIdentity's with different types

  • Loading branch information...
1 parent b11b0f7 commit 8a9e898c9a98db391f164782a3f5cbc2d5839108 @gordalina gordalina committed with fabpot Apr 5, 2013
View
6 src/Symfony/Component/Security/Acl/Dbal/AclProvider.php
@@ -263,7 +263,11 @@ protected function getAncestorLookupSql(array $batch)
for ($i = 0; $i < $count; $i++) {
if (!isset($types[$batch[$i]->getType()])) {
$types[$batch[$i]->getType()] = true;
- if ($count > 1) {
+
+ // if there is more than one type we can safely break out of the
+ // loop, because it is the differentiator factor on whether to
+ // query for only one or more class types
+ if (count($types) > 1) {
break;
}
}
View
17 src/Symfony/Component/Security/Tests/Acl/Dbal/AclProviderTest.php
@@ -72,6 +72,23 @@ public function testFindAcls()
$this->assertTrue($oids[1]->equals($acl1->getObjectIdentity()));
}
+ public function testFindAclsWithDifferentTypes()
+ {
+ $oids = array();
+ $oids[] = new ObjectIdentity('123', 'Bundle\SomeVendor\MyBundle\Entity\SomeEntity');
+ $oids[] = new ObjectIdentity('123', 'Bundle\MyBundle\Entity\AnotherEntity');
+
+ $provider = $this->getProvider();
+
+ $acls = $provider->findAcls($oids);
+ $this->assertInstanceOf('SplObjectStorage', $acls);
+ $this->assertCount(2, $acls);
+ $this->assertInstanceOf('Symfony\Component\Security\Acl\Domain\Acl', $acl0 = $acls->offsetGet($oids[0]));
+ $this->assertInstanceOf('Symfony\Component\Security\Acl\Domain\Acl', $acl1 = $acls->offsetGet($oids[1]));
+ $this->assertTrue($oids[0]->equals($acl0->getObjectIdentity()));
+ $this->assertTrue($oids[1]->equals($acl1->getObjectIdentity()));
+ }
+
public function testFindAclCachesAclInMemory()
{
$oid = new ObjectIdentity('1', 'foo');

0 comments on commit 8a9e898

Please sign in to comment.