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:
parent
9b302a1029
commit
5045254c9f
@ -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');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user