Skip to content

Commit

Permalink
Merge pull request #40507 from nextcloud/backport/40488/stable26
Browse files Browse the repository at this point in the history
[stable26] fix(comments): Use provided offset in best effort when loading comments
  • Loading branch information
nickvergessen authored Sep 20, 2023
2 parents d4d7c3a + e772fe6 commit 59871eb
Showing 1 changed file with 16 additions and 0 deletions.
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

0 comments on commit 59871eb

Please sign in to comment.