diff options
author | Joas Schilling <coding@schilljs.com> | 2023-09-18 20:09:32 +0200 |
---|---|---|
committer | backportbot-nextcloud[bot] <backportbot-nextcloud[bot]@users.noreply.github.com> | 2023-09-19 13:47:51 +0000 |
commit | 9cf4e38c4b588bbf88f38d7899b11de3637330ed (patch) | |
tree | 85a49b21c70d4a9d3567f4a0b67b1aa55a20666a /lib/private/Comments/Manager.php | |
parent | 13c5dde0763131c2ba57f07c840e25083be5aee8 (diff) | |
download | nextcloud-server-9cf4e38c4b588bbf88f38d7899b11de3637330ed.tar.gz nextcloud-server-9cf4e38c4b588bbf88f38d7899b11de3637330ed.zip |
fix(comments): Use provided offset in best effort when loading comments
When we didn't find the "$lastKnownComment" the whole condition was ignored.
Now 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.
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib/private/Comments/Manager.php')
-rw-r--r-- | lib/private/Comments/Manager.php | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/private/Comments/Manager.php b/lib/private/Comments/Manager.php index 117318fb278..7847badd74b 100644 --- a/lib/private/Comments/Manager.php +++ b/lib/private/Comments/Manager.php @@ -548,6 +548,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(); |