diff --git a/lib/private/Accounts/AccountManager.php b/lib/private/Accounts/AccountManager.php index 05feaf87b8..c5a0f21319 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; } 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 d13d5f4186..fcd1a78add 100644 --- a/tests/lib/Accounts/AccountsManagerTest.php +++ b/tests/lib/Accounts/AccountManagerTest.php @@ -34,12 +34,12 @@ use Symfony\Component\EventDispatcher\GenericEvent; 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;