aboutsummaryrefslogtreecommitdiffstats
path: root/apps/user_ldap/lib
diff options
context:
space:
mode:
authorArthur Schiwon <blizzz@arthur-schiwon.de>2021-01-07 19:43:21 +0100
committerArthur Schiwon <blizzz@arthur-schiwon.de>2021-01-07 20:16:40 +0100
commit6eca8d6ae158e613547b7eba1f0dda141a008ee0 (patch)
treef033658adcc1a8e776d7228766f9d6472edf3152 /apps/user_ldap/lib
parent82947263b90bb350501024da58809e7223fc4087 (diff)
downloadnextcloud-server-6eca8d6ae158e613547b7eba1f0dda141a008ee0.tar.gz
nextcloud-server-6eca8d6ae158e613547b7eba1f0dda141a008ee0.zip
respect DB limits of arguments in a IN list
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Diffstat (limited to 'apps/user_ldap/lib')
-rw-r--r--apps/user_ldap/lib/Mapping/AbstractMapping.php22
1 files changed, 17 insertions, 5 deletions
diff --git a/apps/user_ldap/lib/Mapping/AbstractMapping.php b/apps/user_ldap/lib/Mapping/AbstractMapping.php
index 15f95744cd0..64973d7d7cc 100644
--- a/apps/user_ldap/lib/Mapping/AbstractMapping.php
+++ b/apps/user_ldap/lib/Mapping/AbstractMapping.php
@@ -190,18 +190,30 @@ abstract class AbstractMapping {
}
public function getListOfIdsByDn(array $fdns): array {
+ $fdnsSlice = count($fdns) > 1000 ? array_slice($fdns, 0, 1000) : $fdns;
$qb = $this->dbc->getQueryBuilder();
$qb->select('owncloud_name', 'ldap_dn')
->from($this->getTableName(false))
- ->where($qb->expr()->in('ldap_dn', $qb->createNamedParameter($fdns, QueryBuilder::PARAM_STR_ARRAY)));
- $stmt = $qb->execute();
+ ->where($qb->expr()->in('ldap_dn', $qb->createNamedParameter($fdnsSlice, QueryBuilder::PARAM_STR_ARRAY)));
+
+ $slice = 1;
+ while (isset($fdnsSlice[999])) {
+ // Oracle does not allow more than 1000 values in the IN list,
+ // but allows slicing
+ $fdnsSlice = array_slice($fdns, 1000 * $slice, 1000);
+ if (!empty($fdnsSlice)) {
+ $qb->orWhere($qb->expr()->in('ldap_dn', $qb->createNamedParameter($fdnsSlice, QueryBuilder::PARAM_STR_ARRAY)));
+ }
+ $slice++;
+ }
- $results = $stmt->fetchAll(\Doctrine\DBAL\FetchMode::ASSOCIATIVE);
- foreach ($results as $key => $entry) {
- unset($results[$key]);
+ $stmt = $qb->execute();
+ $results = [];
+ while ($entry = $stmt->fetch(\Doctrine\DBAL\FetchMode::ASSOCIATIVE)) {
$results[$entry['ldap_dn']] = $entry['owncloud_name'];
$this->cache[$entry['ldap_dn']] = $entry['owncloud_name'];
}
+ $stmt->closeCursor();
return $results;
}