diff --git a/lib/private/Accounts/AccountManager.php b/lib/private/Accounts/AccountManager.php index 05feaf87b8ff7..c5a0f21319e89 100644 --- a/lib/private/Accounts/AccountManager.php +++ b/lib/private/Accounts/AccountManager.php @@ -229,19 +229,23 @@ public function getUser(IUser $user) { } 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; } diff --git a/tests/lib/Accounts/AccountsManagerTest.php b/tests/lib/Accounts/AccountManagerTest.php similarity index 99% rename from tests/lib/Accounts/AccountsManagerTest.php rename to tests/lib/Accounts/AccountManagerTest.php index d13d5f4186a5a..fcd1a78add71a 100644 --- a/tests/lib/Accounts/AccountsManagerTest.php +++ b/tests/lib/Accounts/AccountManagerTest.php @@ -34,12 +34,12 @@ use Test\TestCase; /** - * Class AccountsManagerTest + * Class AccountManagerTest * * @group DB * @package Test\Accounts */ -class AccountsManagerTest extends TestCase { +class AccountManagerTest extends TestCase { /** @var \OCP\IDBConnection */ private $connection;