[Security][Acl] Reduce query size when Select ACL entries for many instances of the same Type at once
This commit is contained in:
parent
dc4a10e931
commit
3c3a90b9e5
@ -257,19 +257,47 @@ SELECTCLAUSE;
|
|||||||
INNER JOIN {$this->options['oid_ancestors_table_name']} a ON a.object_identity_id = o.id
|
INNER JOIN {$this->options['oid_ancestors_table_name']} a ON a.object_identity_id = o.id
|
||||||
WHERE (
|
WHERE (
|
||||||
SELECTCLAUSE;
|
SELECTCLAUSE;
|
||||||
|
|
||||||
$where = '(o.object_identifier = %s AND c.class_type = %s)';
|
$types = array();
|
||||||
for ($i=0,$c=count($batch); $i<$c; $i++) {
|
for ($i=0,$c=count($batch); $i<$c; $i++) {
|
||||||
$sql .= sprintf(
|
if(!isset($types[$batch[$i]->getType()])) {
|
||||||
$where,
|
$types[$batch[$i]->getType()] = true;
|
||||||
$this->connection->quote($batch[$i]->getIdentifier()),
|
if(count($batch) > 1) {
|
||||||
$this->connection->quote($batch[$i]->getType())
|
break;
|
||||||
);
|
}
|
||||||
|
}
|
||||||
if ($i+1 < $c) {
|
|
||||||
$sql .= ' OR ';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(count($types) === 1) {
|
||||||
|
|
||||||
|
$where = '(o.object_identifier IN (%s) AND c.class_type = %s)';
|
||||||
|
$ids = array();
|
||||||
|
for ($i=0,$c=count($batch); $i<$c; $i++) {
|
||||||
|
$ids[] = $this->connection->quote($batch[$i]->getIdentifier());
|
||||||
|
}
|
||||||
|
|
||||||
|
$sql .= sprintf(
|
||||||
|
$where,
|
||||||
|
implode(',', $ids),
|
||||||
|
$this->connection->quote($batch[0]->getType())
|
||||||
|
);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
$where = '(o.object_identifier = %s AND c.class_type = %s)';
|
||||||
|
for ($i=0,$c=count($batch); $i<$c; $i++) {
|
||||||
|
$sql .= sprintf(
|
||||||
|
$where,
|
||||||
|
$this->connection->quote($batch[$i]->getIdentifier()),
|
||||||
|
$this->connection->quote($batch[$i]->getType())
|
||||||
|
);
|
||||||
|
|
||||||
|
if ($i+1 < $c) {
|
||||||
|
$sql .= ' OR ';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$sql .= ')';
|
$sql .= ')';
|
||||||
|
|
||||||
@ -417,7 +445,7 @@ QUERY;
|
|||||||
* @param array $oidLookup
|
* @param array $oidLookup
|
||||||
*
|
*
|
||||||
* @return \SplObjectStorage mapping object identities to ACL instances
|
* @return \SplObjectStorage mapping object identities to ACL instances
|
||||||
*
|
*
|
||||||
* @throws AclNotFoundException
|
* @throws AclNotFoundException
|
||||||
*/
|
*/
|
||||||
private function lookupObjectIdentities(array $batch, array $sids, array $oidLookup)
|
private function lookupObjectIdentities(array $batch, array $sids, array $oidLookup)
|
||||||
|
Reference in New Issue
Block a user