From 49ed9c7dde2093fa327c09c1b9731d5b760b5466 Mon Sep 17 00:00:00 2001 From: Toby Zerner Date: Mon, 19 Oct 2015 16:18:26 +1030 Subject: [PATCH] Fix error when replying to a post by a deleted user --- extensions/mentions/js/forum/src/addPostReplyAction.js | 3 ++- .../mentions/src/Listener/UpdatePostMentionsMetadata.php | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/extensions/mentions/js/forum/src/addPostReplyAction.js b/extensions/mentions/js/forum/src/addPostReplyAction.js index d774fbec2..6b835bd93 100644 --- a/extensions/mentions/js/forum/src/addPostReplyAction.js +++ b/extensions/mentions/js/forum/src/addPostReplyAction.js @@ -10,7 +10,8 @@ export default function() { if (post.isHidden() || (app.session.user && !post.discussion().canReply())) return; function insertMention(component, quote) { - const mention = '@' + post.user().username() + '#' + post.id() + ' '; + const user = post.user(); + const mention = '@' + (user ? user.username() : post.number()) + '#' + post.id() + ' '; // If the composer is empty, then assume we're starting a new reply. // In which case we don't want the user to have to confirm if they diff --git a/extensions/mentions/src/Listener/UpdatePostMentionsMetadata.php b/extensions/mentions/src/Listener/UpdatePostMentionsMetadata.php index 8e588cd16..077369276 100755 --- a/extensions/mentions/src/Listener/UpdatePostMentionsMetadata.php +++ b/extensions/mentions/src/Listener/UpdatePostMentionsMetadata.php @@ -1,4 +1,4 @@ -whereIn('id', $mentioned) ->get() ->filter(function ($post) use ($reply) { - return $post->user->id !== $reply->user->id; + return $post->user && $post->user->id !== $reply->user_id; }) ->all();