Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 <[email protected]>
  • Loading branch information
nickvergessen authored and backportbot-nextcloud[bot] committed Sep 19, 2023
commit 9cf4e38c4b588bbf88f38d7899b11de3637330ed
16 changes: 16 additions & 0 deletions lib/private/Comments/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,22 @@ public function getCommentsWithVerbForObjectSinceComment(
)
);
}
} 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();
Expand Down