]> git.mxchange.org Git - friendica.git/commitdiff
Fix exceptions in the channel check
authorMichael <heluecht@pirati.ca>
Sat, 25 Nov 2023 16:17:26 +0000 (16:17 +0000)
committerMichael <heluecht@pirati.ca>
Sat, 25 Nov 2023 16:17:26 +0000 (16:17 +0000)
src/Model/Post/Engagement.php
src/Module/Moderation/Reports.php
src/Protocol/ActivityPub/Processor.php

index f88ce3bbc8c984457aeaf90b4dc574fd5238e5aa..a2873d80a8885ee81cfe9dd637d21ae7d30b9ead 100644 (file)
@@ -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 = [
index 4792efe6281443526b1d4450a3a9d251d238e071..1527c9ecf7edd92e5adbf666d0352bb0302292af 100644 (file)
@@ -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;
                        }
index 78a7f37b8cdc9af1768e0452dcbf1e862481e93a..c8e8faed944ae4d7afd788c55956c33e039a9c2f 100644 (file)
@@ -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);
        }