summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorblizzz <blizzz@arthur-schiwon.de>2021-09-27 11:02:14 +0200
committerGitHub <noreply@github.com>2021-09-27 11:02:14 +0200
commit62a5d27eb7633eaf046e50f8ada8e2a2b2239f83 (patch)
tree16088120ce4af4883c3955c5c992a6e8c7ad86b6 /lib
parent4009b3cc57170439f0aefc2cb141250feacf003a (diff)
parent1297b04d41a934d52acd91d406800210dcb653d0 (diff)
downloadnextcloud-server-62a5d27eb7633eaf046e50f8ada8e2a2b2239f83.tar.gz
nextcloud-server-62a5d27eb7633eaf046e50f8ada8e2a2b2239f83.zip
Merge pull request #27203 from nextcloud/backport/27187/stable21
[stable21] Fix Oracle query limit compliance in Comments
Diffstat (limited to 'lib')
-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 64941f55453..e9761cb4310 100644
--- a/lib/private/Comments/Manager.php
+++ b/lib/private/Comments/Manager.php
@@ -633,6 +633,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')
@@ -642,7 +643,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')
@@ -653,12 +654,16 @@ 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();
+ while ($row = $result->fetch()) {
+ $unreadComments[$row['object_id']] = (int) $row['num_comments'];
+ }
+ $result->closeCursor();
}
- $result->closeCursor();
return $unreadComments;
}