Skip to content

Commit

Permalink
Fix mentioning a deleted user's post (#41)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
oddjob79 authored Mar 6, 2020
1 parent b283c39 commit b2c55e2
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/ConfigureMentions.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public static function addPostId($tag)
{
$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);
Expand Down

0 comments on commit b2c55e2

Please sign in to comment.