aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2021-05-28 11:19:36 +0200
committerGitHub <noreply@github.com>2021-05-28 11:19:36 +0200
commitfb7899135e4ac73ef4ad8d547e669207ad096369 (patch)
treede30a9780156adc757894344d5ee2393660b6397 /lib/private
parent0769b174377516b5d7c2598205c9284ded081fe9 (diff)
parenta50eba16adbee809ce69806ee5baee30707b8cca (diff)
downloadnextcloud-server-fb7899135e4ac73ef4ad8d547e669207ad096369.tar.gz
nextcloud-server-fb7899135e4ac73ef4ad8d547e669207ad096369.zip
Merge pull request #27187 from Simounet/fix/comments-query-oracle-limit-compliance
Fix Oracle query limit compliance in Comments
Diffstat (limited to 'lib/private')
-rw-r--r--lib/private/Comments/Manager.php15
1 files changed, 10 insertions, 5 deletions
diff --git a/lib/private/Comments/Manager.php b/lib/private/Comments/Manager.php
index 1cc82b5c2ce..8cd8fc57b3d 100644
--- a/lib/private/Comments/Manager.php
+++ b/lib/private/Comments/Manager.php
@@ -634,6 +634,7 @@ class Manager implements ICommentsManager {
* @since 21.0.0
*/
public function getNumberOfUnreadCommentsForObjects(string $objectType, array $objectIds, IUser $user, $verb = ''): array {
+ $unreadComments = [];
$query = $this->dbConn->getQueryBuilder();
$query->select('c.object_id', $query->func()->count('c.id', 'num_comments'))
->from('comments', 'c')
@@ -643,7 +644,7 @@ class Manager implements ICommentsManager {
$query->expr()->eq('c.object_id', 'm.object_id')
))
->where($query->expr()->eq('c.object_type', $query->createNamedParameter($objectType)))
- ->andWhere($query->expr()->in('c.object_id', $query->createNamedParameter($objectIds, IQueryBuilder::PARAM_STR_ARRAY)))
+ ->andWhere($query->expr()->in('c.object_id', $query->createParameter('ids')))
->andWhere($query->expr()->orX(
$query->expr()->gt('c.creation_timestamp', 'm.marker_datetime'),
$query->expr()->isNull('m.marker_datetime')
@@ -654,10 +655,14 @@ class Manager implements ICommentsManager {
$query->andWhere($query->expr()->eq('c.verb', $query->createNamedParameter($verb)));
}
- $result = $query->execute();
- $unreadComments = array_fill_keys($objectIds, 0);
- while ($row = $result->fetch()) {
- $unreadComments[$row['object_id']] = (int) $row['num_comments'];
+ foreach (array_chunk($objectIds, 1000) as $chunk) {
+ $query->setParameter('ids', $chunk, IQueryBuilder::PARAM_INT_ARRAY);
+ $result = $query->execute();
+
+ $unreadComments += array_fill_keys($objectIds, 0);
+ while ($row = $result->fetch()) {
+ $unreadComments[$row['object_id']] = (int) $row['num_comments'];
+ }
}
$result->closeCursor();