1
0
mirror of https://github.com/flarum/core.git synced 2025-08-03 06:57:54 +02:00

bugfix when posts is not needed when showing discussion (#17)

When accessing /api/discussion/[id]?include=user, NOTICE occurs
This commit is contained in:
lubo
2019-03-25 18:04:31 +08:00
committed by Franz Liedke
parent 979030432f
commit 8ec05c4905

View File

@@ -100,8 +100,10 @@ class AddPostFlagsRelationship
// models) so that we can selectively expose only the flags that the // models) so that we can selectively expose only the flags that the
// user has permission to view. // user has permission to view.
if ($event->isController(Controller\ShowDiscussionController::class)) { if ($event->isController(Controller\ShowDiscussionController::class)) {
if ($event->data->relationLoaded('posts')) {
$posts = $event->data->getRelation('posts'); $posts = $event->data->getRelation('posts');
} }
}
if ($event->isController(Controller\ListPostsController::class)) { if ($event->isController(Controller\ListPostsController::class)) {
$posts = $event->data->all(); $posts = $event->data->all();