From: Michael Date: Sat, 25 Nov 2023 16:17:26 +0000 (+0000) Subject: Fix exceptions in the channel check X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=3f971f6dec88bccea52f685f2ced5fb43d57646b;p=friendica.git Fix exceptions in the channel check --- diff --git a/src/Model/Post/Engagement.php b/src/Model/Post/Engagement.php index f88ce3bbc8..a2873d80a8 100644 --- a/src/Model/Post/Engagement.php +++ b/src/Model/Post/Engagement.php @@ -87,9 +87,10 @@ class Engagement $searchtext = self::getSearchTextForItem($parent); if (!$store) { - $content = trim(($parent['title'] ?? '') . ' ' . ($parent['content-warning'] ?? '') . ' ' . ($parent['body'] ?? '')); - $language = array_key_first(Item::getLanguageArray($content, 1, 0, $parent['author-id'])); - $store = DI::userDefinedChannel()->match($searchtext, $language); + $content = trim(($parent['title'] ?? '') . ' ' . ($parent['content-warning'] ?? '') . ' ' . ($parent['body'] ?? '')); + $languages = Item::getLanguageArray($content, 1, 0, $parent['author-id']); + $language = !empty($languages) ? array_key_first($languages) : ''; + $store = DI::userDefinedChannel()->match($searchtext, $language); } $engagement = [ diff --git a/src/Module/Moderation/Reports.php b/src/Module/Moderation/Reports.php index 4792efe628..1527c9ecf7 100644 --- a/src/Module/Moderation/Reports.php +++ b/src/Module/Moderation/Reports.php @@ -76,7 +76,7 @@ class Reports extends BaseModeration while ($post = $this->database->fetch($posts)) { if (in_array($post['rid'], array_keys($reports))) { $post['created'] = DateTimeFormat::local($post['created'], DateTimeFormat::MYSQL); - $post['body'] = BBCode::toPlaintext($post['body']); + $post['body'] = BBCode::toPlaintext($post['body'] ?? ''); $reports[$post['rid']]['posts'][] = $post; } diff --git a/src/Protocol/ActivityPub/Processor.php b/src/Protocol/ActivityPub/Processor.php index 78a7f37b8c..c8e8faed94 100644 --- a/src/Protocol/ActivityPub/Processor.php +++ b/src/Protocol/ActivityPub/Processor.php @@ -1749,7 +1749,8 @@ class Processor } $searchtext = Engagement::getSearchTextForActivity($content, $authorid, $messageTags, $receivers); - $language = array_key_first(Item::getLanguageArray($content, 1, 0, $authorid)); + $languages = Item::getLanguageArray($content, 1, 0, $authorid); + $language = !empty($languages) ? array_key_first($languages) : ''; return DI::userDefinedChannel()->match($searchtext, $language); }