mirror of
https://github.com/flarum/core.git
synced 2025-07-19 07:41:22 +02:00
Performance: Assign parent discussions to posts so they don't have to be reloaded
This commit is contained in:
@@ -153,7 +153,7 @@ class PostRepository
|
||||
{
|
||||
$discussions = $this->getDiscussionsForPosts($ids, $actor);
|
||||
|
||||
return Post::whereIn('id', $ids)
|
||||
$posts = Post::whereIn('id', $ids)
|
||||
->where(function ($query) use ($discussions, $actor) {
|
||||
foreach ($discussions as $discussion) {
|
||||
$query->orWhere(function ($query) use ($discussion, $actor) {
|
||||
@@ -165,6 +165,12 @@ class PostRepository
|
||||
|
||||
$query->orWhereRaw('FALSE');
|
||||
});
|
||||
|
||||
foreach ($posts as $post) {
|
||||
$post->discussion = $discussions->find($post->discussion_id);
|
||||
}
|
||||
|
||||
return $posts;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user