Fix error when renaming discussion

Discussion/user info is needed when serialising posts (checking permissions, etc.) so we can't just use the ID.
This commit is contained in:
Toby Zerner 2015-11-02 17:53:26 +10:30
parent c719cc6d8a
commit f13ded1255

View File

@ -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;
}
}
}