summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSamuel Gordalina <samuel.gordalina@gmail.com>2013-04-05 13:20:23 +0100
committerFabien Potencier <fabien.potencier@gmail.com>2013-04-07 18:31:20 +0200
commitca59c1631b4d39f134a0768d820e7ba1c5779d0a (patch)
tree407b287be2f7dd8e36c02baa525bbeea22f5b2b9
parent0ca3698f95e20f15f505ddf2d1f949a9857ce14d (diff)
downloadsymfony-security-ca59c1631b4d39f134a0768d820e7ba1c5779d0a.zip
symfony-security-ca59c1631b4d39f134a0768d820e7ba1c5779d0a.tar.gz
symfony-security-ca59c1631b4d39f134a0768d820e7ba1c5779d0a.tar.bz2
Fix finding ACLs from ObjectIdentity's with different types
-rw-r--r--Acl/Dbal/AclProvider.php6
-rw-r--r--Tests/Acl/Dbal/AclProviderTest.php17
2 files changed, 22 insertions, 1 deletions
diff --git a/Acl/Dbal/AclProvider.php b/Acl/Dbal/AclProvider.php
index 6f47231..822a160 100644
--- a/Acl/Dbal/AclProvider.php
+++ b/Acl/Dbal/AclProvider.php
@@ -263,7 +263,11 @@ SELECTCLAUSE;
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;
}
}
diff --git a/Tests/Acl/Dbal/AclProviderTest.php b/Tests/Acl/Dbal/AclProviderTest.php
index 83771ee..ad58d72 100644
--- a/Tests/Acl/Dbal/AclProviderTest.php
+++ b/Tests/Acl/Dbal/AclProviderTest.php
@@ -72,6 +72,23 @@ class AclProviderTest extends \PHPUnit_Framework_TestCase
$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');