aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/Accounts
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2021-03-12 08:49:23 +0100
committerJoas Schilling <coding@schilljs.com>2021-03-12 08:49:23 +0100
commit2e08c8b5a1909e721a85fbfc92102a6218305506 (patch)
tree38e524360c0eee19eb9537a1cf58936cece8bb38 /lib/private/Accounts
parent56b08c04c739dc5ad1cc0e924004fa8acc2ce3ac (diff)
downloadnextcloud-server-2e08c8b5a1909e721a85fbfc92102a6218305506.tar.gz
nextcloud-server-2e08c8b5a1909e721a85fbfc92102a6218305506.zip
Chunk the array of phone numbers
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib/private/Accounts')
-rw-r--r--lib/private/Accounts/AccountManager.php14
1 files changed, 9 insertions, 5 deletions
diff --git a/lib/private/Accounts/AccountManager.php b/lib/private/Accounts/AccountManager.php
index 05feaf87b8f..c5a0f21319e 100644
--- a/lib/private/Accounts/AccountManager.php
+++ b/lib/private/Accounts/AccountManager.php
@@ -229,19 +229,23 @@ class AccountManager implements IAccountManager {
}
public function searchUsers(string $property, array $values): array {
+ $chunks = array_chunk($values, 500);
$query = $this->connection->getQueryBuilder();
$query->select('*')
->from($this->dataTable)
->where($query->expr()->eq('name', $query->createNamedParameter($property)))
- ->andWhere($query->expr()->in('value', $query->createNamedParameter($values, IQueryBuilder::PARAM_STR_ARRAY)));
+ ->andWhere($query->expr()->in('value', $query->createParameter('values')));
- $result = $query->execute();
$matches = [];
+ foreach ($chunks as $chunk) {
+ $query->setParameter('values', $chunk, IQueryBuilder::PARAM_STR_ARRAY);
+ $result = $query->execute();
- while ($row = $result->fetch()) {
- $matches[$row['value']] = $row['uid'];
+ while ($row = $result->fetch()) {
+ $matches[$row['value']] = $row['uid'];
+ }
+ $result->closeCursor();
}
- $result->closeCursor();
return $matches;
}