diff options
author | Joas Schilling <coding@schilljs.com> | 2021-03-12 08:49:23 +0100 |
---|---|---|
committer | backportbot[bot] <backportbot[bot]@users.noreply.github.com> | 2021-03-12 10:23:13 +0000 |
commit | 6951c4ef56c26c03851ee986834558622768dea9 (patch) | |
tree | af0a22980ae188f5e7bd7a73b170d3562a056abc | |
parent | 6e2f7ddc7ae031d52853943c2f5fa46e85681892 (diff) | |
download | nextcloud-server-6951c4ef56c26c03851ee986834558622768dea9.tar.gz nextcloud-server-6951c4ef56c26c03851ee986834558622768dea9.zip |
Chunk the array of phone numbers
Signed-off-by: Joas Schilling <coding@schilljs.com>
-rw-r--r-- | lib/private/Accounts/AccountManager.php | 14 |
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; } |