* @param string $sortDirection direction of the comments (`asc` or `desc`)
* @param int $limit optional, number of maximum comments to be returned. if
* set to 0, all comments are returned.
+ * @param bool $includeLastKnown
* @return IComment[]
* @return array
*/
string $objectId,
int $lastKnownCommentId,
string $sortDirection = 'asc',
- int $limit = 30
+ int $limit = 30,
+ bool $includeLastKnown = false
): array {
$comments = [];
if ($lastKnownComment instanceof IComment) {
$lastKnownCommentDateTime = $lastKnownComment->getCreationDateTime();
if ($sortDirection === 'desc') {
+ $idComparison = $includeLastKnown ? 'lte' : 'lt';
$query->andWhere(
$query->expr()->orX(
$query->expr()->lt(
$query->createNamedParameter($lastKnownCommentDateTime, IQueryBuilder::PARAM_DATE),
IQueryBuilder::PARAM_DATE
),
- $query->expr()->lt('id', $query->createNamedParameter($lastKnownCommentId))
+ $query->expr()->$idComparison('id', $query->createNamedParameter($lastKnownCommentId))
)
)
);
} else {
+ $idComparison = $includeLastKnown ? 'gte' : 'gt';
$query->andWhere(
$query->expr()->orX(
$query->expr()->gt(
$query->createNamedParameter($lastKnownCommentDateTime, IQueryBuilder::PARAM_DATE),
IQueryBuilder::PARAM_DATE
),
- $query->expr()->gt('id', $query->createNamedParameter($lastKnownCommentId))
+ $query->expr()->$idComparison('id', $query->createNamedParameter($lastKnownCommentId))
)
)
);
* @param string $sortDirection direction of the comments (`asc` or `desc`)
* @param int $limit optional, number of maximum comments to be returned. if
* set to 0, all comments are returned.
+ * @param bool $includeLastKnown
* @return IComment[]
* @since 14.0.0
*/
string $objectId,
int $lastKnownCommentId,
string $sortDirection = 'asc',
- int $limit = 30
+ int $limit = 30,
+ bool $includeLastKnown = false
): array;
/**