merged branch stloyd/feature/acl_query (PR #6597)
This PR was merged into the master branch. Commits -------d570dbe
[Security][Acl] CS fix for commit:3c3a90b9e5
3c3a90b
[Security][Acl] Reduce query size when Select ACL entries for many instances of the same Type at once Discussion ---------- [Security][Acl] Reduce query size when select ACL type is same Rebased & squashed version of #6479. ps. I was thinking that this could be done on _lower_ versions too, but was not sure =)
This commit is contained in:
commit
1e6258846a
@ -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++) {
|
||||
$sql .= sprintf(
|
||||
$where,
|
||||
$this->connection->quote($batch[$i]->getIdentifier()),
|
||||
$this->connection->quote($batch[$i]->getType())
|
||||
);
|
||||
$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 ($i+1 < $c) {
|
||||
$sql .= ' OR ';
|
||||
if (1 === count($types)) {
|
||||
$ids = array();
|
||||
for ($i = 0; $i < $count; $i++) {
|
||||
$ids[] = $this->connection->quote($batch[$i]->getIdentifier());
|
||||
}
|
||||
|
||||
$sql .= sprintf(
|
||||
'(o.object_identifier IN (%s) AND c.class_type = %s)',
|
||||
implode(',', $ids),
|
||||
$this->connection->quote($batch[0]->getType())
|
||||
);
|
||||
} 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 ';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user