From aa95ac6bc811e6dca4e04410467b94b4f0170c99 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 23 Mar 2016 11:13:59 +0100 Subject: Chunk the shareId query --- .../lib/propagation/recipientpropagator.php | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'apps') diff --git a/apps/files_sharing/lib/propagation/recipientpropagator.php b/apps/files_sharing/lib/propagation/recipientpropagator.php index 407664f31b7..86c22a93628 100644 --- a/apps/files_sharing/lib/propagation/recipientpropagator.php +++ b/apps/files_sharing/lib/propagation/recipientpropagator.php @@ -133,20 +133,25 @@ class RecipientPropagator { */ protected function getPropagationTimestampForShares(array $sharePropagations) { $sql = \OC::$server->getDatabaseConnection()->getQueryBuilder(); - $shareIds = array_keys($sharePropagations); + $allShareIds = array_keys($sharePropagations); + + $shareIdChunks = array_chunk($allShareIds, 50); $sql->select(['configkey', 'configvalue']) ->from('appconfig') ->where($sql->expr()->eq('appid', $sql->createParameter('appid'))) ->andWhere($sql->expr()->in('configkey', $sql->createParameter('shareids'))) - ->setParameter('appid', 'files_sharing', \PDO::PARAM_STR) - ->setParameter('shareids', $shareIds, Connection::PARAM_INT_ARRAY); - $result = $sql->execute(); + ->setParameter('appid', 'files_sharing', \PDO::PARAM_STR); + + foreach ($shareIdChunks as $shareIds) { + $sql->setParameter('shareids', $shareIds, Connection::PARAM_INT_ARRAY); + $result = $sql->execute(); - while ($row = $result->fetch()) { - $sharePropagations[(int) $row['configkey']] = $row['configvalue']; + while ($row = $result->fetch()) { + $sharePropagations[(int) $row['configkey']] = $row['configvalue']; + } + $result->closeCursor(); } - $result->closeCursor(); return $sharePropagations; } -- cgit v1.2.3