mirror of
https://github.com/flarum/framework.git
synced 2024-11-25 17:57:04 +08:00
Eager load discussion relationships
Since extensions may add nested includes, we need to make sure they are eager-loaded to avoid excessive queries. For example, when the tags extension adds "tags" and "tags.state".
This commit is contained in:
parent
aeb0a411b9
commit
dd209b1747
|
@ -83,6 +83,10 @@ class ShowDiscussionController extends AbstractResourceController
|
|||
$this->includePosts($discussion, $request, $postRelationships);
|
||||
}
|
||||
|
||||
$discussion->load(array_filter($include, function ($relationship) {
|
||||
return ! starts_with($relationship, 'posts');
|
||||
}));
|
||||
|
||||
return $discussion;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user