]> git.mxchange.org Git - friendica.git/commitdiff
Skip URL-less mention terms in Object\Post::getDefaultText
authorHypolite Petovan <hypolite@mrpetovan.com>
Tue, 11 May 2021 01:50:42 +0000 (21:50 -0400)
committerHypolite Petovan <hypolite@mrpetovan.com>
Tue, 11 May 2021 01:50:42 +0000 (21:50 -0400)
- Address https://github.com/friendica/friendica/issues/10167#issuecomment-830859710
- Added logging to troubleshoot deeper issue

src/Object/Post.php

index 6973fd236a3064c92b1fd0102a731a0128566c56..ba8c709de85edb12fa2c3368589f8a01ff2c1b04 100644 (file)
@@ -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'] . ' ';
                        }