Skip to content

Commit

Permalink
bugfix when posts is not needed when showing discussion (#17)
Browse files Browse the repository at this point in the history
When accessing /api/discussion/[id]?include=user, NOTICE occurs
  • Loading branch information
lubobill1990 authored and franzliedke committed Mar 25, 2019
1 parent 087bad7 commit 9803914
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/Listener/AddPostFlagsRelationship.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,9 @@ public function prepareApiData(WillSerializeData $event)
// models) so that we can selectively expose only the flags that the
// user has permission to view.
if ($event->isController(Controller\ShowDiscussionController::class)) {
$posts = $event->data->getRelation('posts');
if ($event->data->relationLoaded('posts')) {
$posts = $event->data->getRelation('posts');
}
}

if ($event->isController(Controller\ListPostsController::class)) {
Expand Down

0 comments on commit 9803914

Please sign in to comment.