Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(comments): Use provided offset in best effort when loading comments #40488

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 16 additions & 0 deletions lib/private/Comments/Manager.php
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