diff options
Diffstat (limited to 'Acl/Dbal/AclProvider.php')
-rw-r--r-- | Acl/Dbal/AclProvider.php | 44 |
1 files changed, 35 insertions, 9 deletions
diff --git a/Acl/Dbal/AclProvider.php b/Acl/Dbal/AclProvider.php index 8413843..6f47231 100644 --- a/Acl/Dbal/AclProvider.php +++ b/Acl/Dbal/AclProvider.php @@ -258,16 +258,40 @@ SELECTCLAUSE; WHERE ( SELECTCLAUSE; - $where = '(o.object_identifier = %s AND c.class_type = %s)'; - for ($i=0,$c=count($batch); $i<$c; $i++) { + $types = array(); + $count = count($batch); + for ($i = 0; $i < $count; $i++) { + if (!isset($types[$batch[$i]->getType()])) { + $types[$batch[$i]->getType()] = true; + if ($count > 1) { + break; + } + } + } + + if (1 === count($types)) { + $ids = array(); + for ($i = 0; $i < $count; $i++) { + $ids[] = $this->connection->quote($batch[$i]->getIdentifier()); + } + $sql .= sprintf( - $where, - $this->connection->quote($batch[$i]->getIdentifier()), - $this->connection->quote($batch[$i]->getType()) + '(o.object_identifier IN (%s) AND c.class_type = %s)', + implode(',', $ids), + $this->connection->quote($batch[0]->getType()) ); - - if ($i+1 < $c) { - $sql .= ' OR '; + } else { + $where = '(o.object_identifier = %s AND c.class_type = %s)'; + for ($i = 0; $i < $count; $i++) { + $sql .= sprintf( + $where, + $this->connection->quote($batch[$i]->getIdentifier()), + $this->connection->quote($batch[$i]->getType()) + ); + + if ($i+1 < $count) { + $sql .= ' OR '; + } } } @@ -339,7 +363,7 @@ QUERY; * @param ObjectIdentityInterface $oid * @return integer */ - protected final function retrieveObjectIdentityPrimaryKey(ObjectIdentityInterface $oid) + final protected function retrieveObjectIdentityPrimaryKey(ObjectIdentityInterface $oid) { return $this->connection->executeQuery($this->getSelectObjectIdentityIdSql($oid))->fetchColumn(); } @@ -417,6 +441,8 @@ QUERY; * @param array $oidLookup * * @return \SplObjectStorage mapping object identities to ACL instances + * + * @throws AclNotFoundException */ private function lookupObjectIdentities(array $batch, array $sids, array $oidLookup) { |