From 9c674f0a8b39d32bc4daf886970e6488bf57b5e7 Mon Sep 17 00:00:00 2001 From: Robert Turner <28482378+oddjob79@users.noreply.github.com> Date: Fri, 6 Mar 2020 23:04:24 +0100 Subject: [PATCH] Fix mentioning a deleted user's post (#41) Fixes #1956 - ErrorException: Trying to get property 'display_name' of non-object. ConfigureMentions::addPostId method set mention details based on if there was an existing post. This caused an error if there was an existing post, but the user who posted had been deleted. The mention details are now only set if there is a user associated with the post being mentioned. --- extensions/mentions/src/ConfigureMentions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/mentions/src/ConfigureMentions.php b/extensions/mentions/src/ConfigureMentions.php index 0b9e0975c..f942a1a31 100644 --- a/extensions/mentions/src/ConfigureMentions.php +++ b/extensions/mentions/src/ConfigureMentions.php @@ -99,7 +99,7 @@ class ConfigureMentions { $post = CommentPost::find($tag->getAttribute('id')); - if ($post) { + if ($post && $post->user) { $tag->setAttribute('discussionid', (int) $post->discussion_id); $tag->setAttribute('number', (int) $post->number); $tag->setAttribute('displayname', $post->user->display_name);