mirror of
https://github.com/flarum/framework.git
synced 2024-11-25 06:14:33 +08:00
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:
parent
c719cc6d8a
commit
f13ded1255
|
@ -13,6 +13,7 @@ namespace Flarum\Api\Controller;
|
||||||
use Flarum\Core\Command\EditDiscussion;
|
use Flarum\Core\Command\EditDiscussion;
|
||||||
use Flarum\Core\Command\ReadDiscussion;
|
use Flarum\Core\Command\ReadDiscussion;
|
||||||
use Illuminate\Contracts\Bus\Dispatcher;
|
use Illuminate\Contracts\Bus\Dispatcher;
|
||||||
|
use Illuminate\Database\Eloquent\Collection;
|
||||||
use Psr\Http\Message\ServerRequestInterface;
|
use Psr\Http\Message\ServerRequestInterface;
|
||||||
use Tobscure\JsonApi\Document;
|
use Tobscure\JsonApi\Document;
|
||||||
|
|
||||||
|
@ -60,14 +61,13 @@ class UpdateDiscussionController extends AbstractResourceController
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($posts = $discussion->getModifiedPosts()) {
|
if ($posts = $discussion->getModifiedPosts()) {
|
||||||
|
$posts = (new Collection($posts))->load('discussion', 'user');
|
||||||
$discussionPosts = $discussion->postsVisibleTo($actor)->orderBy('time')->lists('id')->all();
|
$discussionPosts = $discussion->postsVisibleTo($actor)->orderBy('time')->lists('id')->all();
|
||||||
|
|
||||||
foreach ($discussionPosts as &$id) {
|
foreach ($discussionPosts as &$id) {
|
||||||
foreach ($posts as $post) {
|
foreach ($posts as $post) {
|
||||||
if ($id == $post->id) {
|
if ($id == $post->id) {
|
||||||
$id = $post;
|
$id = $post;
|
||||||
$post->discussion = $post->discussion_id;
|
|
||||||
$post->user = $post->user_id;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user