aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoas Schilling <213943+nickvergessen@users.noreply.github.com>2023-09-19 15:30:57 +0200
committerGitHub <noreply@github.com>2023-09-19 15:30:57 +0200
commit2bd0f07e5a1bb1a83ec3b1c86c1a1271dcdad9e3 (patch)
treeb18b779586533c565fba0f661612f0bf0f5984be
parentb6761fbc967bd165279ca20af8c05cae045267d4 (diff)
parent4d2217073acf6ed844bd006c102e403e7978e813 (diff)
downloadnextcloud-server-2bd0f07e5a1bb1a83ec3b1c86c1a1271dcdad9e3.tar.gz
nextcloud-server-2bd0f07e5a1bb1a83ec3b1c86c1a1271dcdad9e3.zip
Merge pull request #40488 from nextcloud/bugfix/noid/message-expiration-breaks-pagination
fix(comments): Use provided offset in best effort when loading comments
-rw-r--r--lib/private/Comments/Manager.php16
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/private/Comments/Manager.php b/lib/private/Comments/Manager.php
index af4fda277d6..725febef85d 100644
--- a/lib/private/Comments/Manager.php
+++ b/lib/private/Comments/Manager.php
@@ -501,6 +501,22 @@ class Manager implements ICommentsManager {
)
);
}
+ } elseif ($lastKnownCommentId > 0) {
+ // We didn't find the "$lastKnownComment" but we still use the ID as an offset.
+ // This is required as a fall-back for expired messages in talk and deleted comments in other apps.
+ if ($sortDirection === 'desc') {
+ if ($includeLastKnown) {
+ $query->andWhere($query->expr()->lte('id', $query->createNamedParameter($lastKnownCommentId)));
+ } else {
+ $query->andWhere($query->expr()->lt('id', $query->createNamedParameter($lastKnownCommentId)));
+ }
+ } else {
+ if ($includeLastKnown) {
+ $query->andWhere($query->expr()->gte('id', $query->createNamedParameter($lastKnownCommentId)));
+ } else {
+ $query->andWhere($query->expr()->gt('id', $query->createNamedParameter($lastKnownCommentId)));
+ }
+ }
}
$resultStatement = $query->execute();