1
0
mirror of https://github.com/flarum/core.git synced 2025-07-28 20:20:34 +02:00

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.
This commit is contained in:
Robert Turner
2020-03-06 23:04:24 +01:00
committed by GitHub
parent 090483e3ab
commit 9c674f0a8b

View File

@@ -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);