diff --git a/framework/core/src/Post/CommentPost.php b/framework/core/src/Post/CommentPost.php index 7455abc120..35f38e8528 100644 --- a/framework/core/src/Post/CommentPost.php +++ b/framework/core/src/Post/CommentPost.php @@ -75,12 +75,14 @@ public static function reply($discussionId, $content, $userId, $ipAddress, User public function revise($content, User $actor) { if ($this->content !== $content) { + $oldContent = $this->content; + $this->setContentAttribute($content, $actor); $this->edited_at = Carbon::now(); $this->edited_user_id = $actor->id; - $this->raise(new Revised($this)); + $this->raise(new Revised($this, $actor, $oldContent)); } return $this; diff --git a/framework/core/src/Post/Event/Revised.php b/framework/core/src/Post/Event/Revised.php index 72281e13a6..8d4f857252 100644 --- a/framework/core/src/Post/Event/Revised.php +++ b/framework/core/src/Post/Event/Revised.php @@ -15,7 +15,7 @@ class Revised { /** - * @var \Flarum\Post\CommentPost + * @var CommentPost */ public $post; @@ -25,11 +25,18 @@ class Revised public $actor; /** - * @param \Flarum\Post\CommentPost $post + * We manually set the old content because at this stage the post + * has already been updated with the new content. So the original + * content is not available anymore. + * + * @var string */ - public function __construct(CommentPost $post, User $actor = null) + public $oldContent; + + public function __construct(CommentPost $post, User $actor, string $oldContent) { $this->post = $post; $this->actor = $actor; + $this->oldContent = $oldContent; } }