From f13ded1255de93e72ebffdf27cb4a64be2f7e0dd Mon Sep 17 00:00:00 2001 From: Toby Zerner Date: Mon, 2 Nov 2015 17:53:26 +1030 Subject: [PATCH] Fix error when renaming discussion Discussion/user info is needed when serialising posts (checking permissions, etc.) so we can't just use the ID. --- src/Api/Controller/UpdateDiscussionController.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Api/Controller/UpdateDiscussionController.php b/src/Api/Controller/UpdateDiscussionController.php index c34150c24..6945de3f0 100644 --- a/src/Api/Controller/UpdateDiscussionController.php +++ b/src/Api/Controller/UpdateDiscussionController.php @@ -13,6 +13,7 @@ namespace Flarum\Api\Controller; use Flarum\Core\Command\EditDiscussion; use Flarum\Core\Command\ReadDiscussion; use Illuminate\Contracts\Bus\Dispatcher; +use Illuminate\Database\Eloquent\Collection; use Psr\Http\Message\ServerRequestInterface; use Tobscure\JsonApi\Document; @@ -60,14 +61,13 @@ class UpdateDiscussionController extends AbstractResourceController } if ($posts = $discussion->getModifiedPosts()) { + $posts = (new Collection($posts))->load('discussion', 'user'); $discussionPosts = $discussion->postsVisibleTo($actor)->orderBy('time')->lists('id')->all(); foreach ($discussionPosts as &$id) { foreach ($posts as $post) { if ($id == $post->id) { $id = $post; - $post->discussion = $post->discussion_id; - $post->user = $post->user_id; } } }