1
0
mirror of https://github.com/flarum/core.git synced 2025-01-16 13:51:46 +01:00

fix: unread filter gambit does not return results when > 999 read discussions for a user (#3295)

This commit is contained in:
Ian Morland 2022-03-09 20:41:04 +00:00 committed by GitHub
parent 9b302a1029
commit 5045254c9f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 3 deletions

View File

@ -42,16 +42,29 @@ class DiscussionRepository
/**
* Get the IDs of discussions which a user has read completely.
*
* @deprecated 1.3 Use `getReadIdsQuery` instead
*
* @param User $user
* @return array
*/
public function getReadIds(User $user)
{
return $this->getReadIdsQuery($user)
->all();
}
/**
* Get a query containing the IDs of discussions which a user has read completely.
*
* @param User $user
* @return Builder
*/
public function getReadIdsQuery(User $user): Builder
{
return Discussion::leftJoin('discussion_user', 'discussion_user.discussion_id', '=', 'discussions.id')
->where('discussion_user.user_id', $user->id)
->whereColumn('last_read_post_number', '>=', 'last_post_number')
->pluck('id')
->all();
->select('id');
}
/**

View File

@ -61,7 +61,7 @@ class UnreadFilterGambit extends AbstractRegexGambit implements FilterInterface
protected function constrain(Builder $query, User $actor, bool $negate)
{
if ($actor->exists) {
$readIds = $this->discussions->getReadIds($actor);
$readIds = $this->discussions->getReadIdsQuery($actor);
$query->where(function ($query) use ($readIds, $negate, $actor) {
if (! $negate) {