From 9ef9fc7c14991cc69082b9b763e30a9473329546 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Mon, 10 May 2021 21:50:42 -0400 Subject: [PATCH] Skip URL-less mention terms in Object\Post::getDefaultText - Address https://github.com/friendica/friendica/issues/10167#issuecomment-830859710 - Added logging to troubleshoot deeper issue --- src/Object/Post.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Object/Post.php b/src/Object/Post.php index 6973fd236a..ba8c709de8 100644 --- a/src/Object/Post.php +++ b/src/Object/Post.php @@ -887,8 +887,13 @@ class Post $terms = Tag::getByURIId($item['uri-id'], [Tag::MENTION, Tag::IMPLICIT_MENTION, Tag::EXCLUSIVE_MENTION]); foreach ($terms as $term) { + if (!$term['url']) { + DI::logger()->warning('Mention term with no URL', ['term' => $term]); + continue; + } + $profile = Contact::getByURL($term['url'], false, ['addr', 'contact-type']); - if (!empty($profile['addr']) && ((($profile['contact-type'] ?? '') ?: Contact::TYPE_UNKNOWN) != Contact::TYPE_COMMUNITY) && + if (!empty($profile['addr']) && (($profile['contact-type'] ?? Contact::TYPE_UNKNOWN) != Contact::TYPE_COMMUNITY) && ($profile['addr'] != $owner['addr']) && !strstr($text, $profile['addr'])) { $text .= '@' . $profile['addr'] . ' '; }