mirror of
https://github.com/flarum/core.git
synced 2025-10-18 10:16:09 +02:00
Wrap column names; use whereColumn where possible
This commit is contained in:
@@ -121,13 +121,9 @@ class Post extends AbstractModel
|
||||
|
||||
// Make sure the post's discussion is visible as well
|
||||
$query->whereExists(function ($query) use ($actor) {
|
||||
$grammar = $query->getGrammar();
|
||||
$column1 = $grammar->wrap('discussions.id');
|
||||
$column2 = $grammar->wrap('posts.discussion_id');
|
||||
|
||||
$query->selectRaw('1')
|
||||
->from('discussions')
|
||||
->whereRaw("$column1 = $column2");
|
||||
->whereColumn('discussions.id', 'posts.discussion_id');
|
||||
|
||||
static::$dispatcher->dispatch(
|
||||
new ScopeModelVisibility(Discussion::query()->setQuery($query), $actor, 'view')
|
||||
|
@@ -86,7 +86,7 @@ class PostPolicy extends AbstractPolicy
|
||||
->orWhereExists(function ($query) use ($actor) {
|
||||
$query->selectRaw('1')
|
||||
->from('discussions')
|
||||
->whereRaw('discussions.id = posts.discussion_id')
|
||||
->whereColumn('discussions.id', 'posts.discussion_id')
|
||||
->where(function ($query) use ($actor) {
|
||||
$this->events->dispatch(
|
||||
new ScopeModelVisibility(Discussion::query()->setQuery($query), $actor, 'hidePosts')
|
||||
|
Reference in New Issue
Block a user