mirror of
https://github.com/flarum/framework.git
synced 2024-11-29 21:11:55 +08:00
Make sure query filter works with database prefix, too.
Related to flarum/core#269.
This commit is contained in:
parent
7b24c82f6f
commit
b290161ef4
|
@ -3,6 +3,7 @@
|
|||
use Flarum\Tags\TagRepository;
|
||||
use Flarum\Core\Search\Search;
|
||||
use Flarum\Core\Search\RegexGambit;
|
||||
use Illuminate\Database\Query\Expression;
|
||||
|
||||
class TagGambit extends RegexGambit
|
||||
{
|
||||
|
@ -32,7 +33,7 @@ class TagGambit extends RegexGambit
|
|||
$query->orWhereNotExists(function ($query) {
|
||||
$query->select(app('flarum.db')->raw(1))
|
||||
->from('discussions_tags')
|
||||
->whereRaw('discussion_id = discussions.id');
|
||||
->where('discussions.id', new Expression('discussion_id'));
|
||||
});
|
||||
} else {
|
||||
$id = $this->tags->getIdForSlug($slug);
|
||||
|
@ -40,7 +41,8 @@ class TagGambit extends RegexGambit
|
|||
$query->orWhereExists(function ($query) use ($id) {
|
||||
$query->select(app('flarum.db')->raw(1))
|
||||
->from('discussions_tags')
|
||||
->whereRaw('discussion_id = discussions.id AND tag_id = ?', [$id]);
|
||||
->where('discussions.id', new Expression('discussion_id'))
|
||||
->where('tag_id', $id);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ use Flarum\Events\DiscussionSearchWillBePerformed;
|
|||
use Illuminate\Contracts\Events\Dispatcher;
|
||||
use Flarum\Tags\Gambits\TagGambit;
|
||||
use Flarum\Tags\Tag;
|
||||
use Illuminate\Database\Query\Expression;
|
||||
|
||||
class AddTagGambit
|
||||
{
|
||||
|
@ -33,7 +34,7 @@ class AddTagGambit
|
|||
return $query->select(app('flarum.db')->raw(1))
|
||||
->from('discussions_tags')
|
||||
->whereIn('tag_id', Tag::where('is_hidden', 1)->lists('id'))
|
||||
->whereRaw('discussion_id = ' . app('flarum.db')->getQueryGrammar()->wrap('discussions.id'));
|
||||
->where('discussions.id', new Expression('discussion_id'));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ use Flarum\Events\ScopeModelVisibility;
|
|||
use Flarum\Events\ModelAllow;
|
||||
use Flarum\Core\Discussions\Discussion;
|
||||
use Flarum\Tags\Tag;
|
||||
use Illuminate\Database\Query\Expression;
|
||||
|
||||
class ConfigureDiscussionPermissions
|
||||
{
|
||||
|
@ -21,7 +22,7 @@ class ConfigureDiscussionPermissions
|
|||
return $query->select(app('flarum.db')->raw(1))
|
||||
->from('discussions_tags')
|
||||
->whereIn('tag_id', Tag::getNotVisibleTo($event->actor))
|
||||
->whereRaw('discussion_id = ' . app('flarum.db')->getQueryGrammar()->wrap('discussions.id'));
|
||||
->where('discussions.id', new Expression('discussion_id'));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user