mirror of
https://github.com/flarum/framework.git
synced 2025-02-27 19:15:41 +08:00
Fixes flarum/core#2168 negated tags not working (#88)
orWhereIn doesn't have the $not parameter and the argument was ignored by PHP
This commit is contained in:
parent
d105879392
commit
bf223071f2
@ -12,6 +12,7 @@ namespace Flarum\Tags\Gambit;
|
||||
use Flarum\Search\AbstractRegexGambit;
|
||||
use Flarum\Search\AbstractSearch;
|
||||
use Flarum\Tags\TagRepository;
|
||||
use Illuminate\Database\Query\Builder;
|
||||
|
||||
class TagGambit extends AbstractRegexGambit
|
||||
{
|
||||
@ -40,21 +41,21 @@ class TagGambit extends AbstractRegexGambit
|
||||
{
|
||||
$slugs = explode(',', trim($matches[1], '"'));
|
||||
|
||||
$search->getQuery()->where(function ($query) use ($slugs, $negate) {
|
||||
$search->getQuery()->where(function (Builder $query) use ($slugs, $negate) {
|
||||
foreach ($slugs as $slug) {
|
||||
if ($slug === 'untagged') {
|
||||
$query->orWhereIn('discussions.id', function ($query) {
|
||||
$query->whereIn('discussions.id', function (Builder $query) {
|
||||
$query->select('discussion_id')
|
||||
->from('discussion_tag');
|
||||
}, ! $negate);
|
||||
}, 'or', ! $negate);
|
||||
} else {
|
||||
$id = $this->tags->getIdForSlug($slug);
|
||||
|
||||
$query->orWhereIn('discussions.id', function ($query) use ($id) {
|
||||
$query->whereIn('discussions.id', function (Builder $query) use ($id) {
|
||||
$query->select('discussion_id')
|
||||
->from('discussion_tag')
|
||||
->where('tag_id', $id);
|
||||
}, $negate);
|
||||
}, 'or', $negate);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user