Skip to content

Commit

Permalink
Merge pull request #40488 from nextcloud/bugfix/noid/message-expirati…
Browse files Browse the repository at this point in the history
…on-breaks-pagination

fix(comments): Use provided offset in best effort when loading comments
  • Loading branch information
nickvergessen authored Sep 19, 2023
2 parents b6761fb + 4d22170 commit 2bd0f07
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 @@ -501,6 +501,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 2bd0f07

Please sign in to comment.