Merge pull request #40509 from nextcloud/backport/40488/stable25

[stable25] fix(comments): Use provided offset in best effort when loading comments
This commit is contained in:
Joas Schilling 2023-09-20 10:24:09 +02:00 committed by GitHub
commit 163ace279b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -549,6 +549,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();