]> git.mxchange.org Git - friendica.git/commitdiff
Merge pull request #9530 from annando/fatal
authorHypolite Petovan <hypolite@mrpetovan.com>
Thu, 12 Nov 2020 12:57:53 +0000 (07:57 -0500)
committerGitHub <noreply@github.com>
Thu, 12 Nov 2020 12:57:53 +0000 (07:57 -0500)
Fix fatal errors

src/Protocol/ActivityPub/Transmitter.php
src/Protocol/Feed.php

index 6ac55dc12317946ca22392cc9a9c3941634cb18c..5fc27015ba8580883b45bd35bced11cc60401a38 100644 (file)
@@ -995,11 +995,19 @@ class Transmitter
                        if (!empty($author['nurl'])) {
                                $self = Contact::selectFirst(['uid'], ['nurl' => $author['nurl'], 'self' => true]);
                                if (!empty($self['uid'])) {
-                                       $item = Item::selectFirst([], ['uri-id' => $item['uri-id'], 'uid' => $self['uid']]);
+                                       $forum_item = Item::selectFirst([], ['uri-id' => $item['uri-id'], 'uid' => $self['uid']]);
+                                       if (DBA::isResult($item)) {
+                                               $item = $forum_item; 
+                                       }
                                }
                        }
                }
 
+               if (empty($item['uri-id'])) {
+                       Logger::warning('Item without uri-id', ['item' => $item]);
+                       return false;
+               }
+
                if (empty($type)) {
                        $condition = ['item-uri' => $item['uri'], 'protocol' => Conversation::PARCEL_ACTIVITYPUB];
                        $conversation = DBA::selectFirst('conversation', ['source'], $condition);
index 89e7d75423bf6c5e6ac64edb08b3ad83bae3e73e..fee765f25b943183f5f93b6b9eb77c2722ba05b2 100644 (file)
@@ -552,25 +552,27 @@ class Feed
 
                                $data = PageInfo::queryUrl($item["plink"], false, $preview, ($contact["fetch_further_information"] == 2), $contact["ffi_keyword_denylist"] ?? '');
 
-                               // Take the data that was provided by the feed if the query is empty
-                               if (($data['type'] == 'link') && empty($data['title']) && empty($data['text'])) {
-                                       $data['title'] = $saved_title;
-                                       $item["body"] = $saved_body;
-                               }
+                               if (!empty($data)) {
+                                       // Take the data that was provided by the feed if the query is empty
+                                       if (($data['type'] == 'link') && empty($data['title']) && empty($data['text'])) {
+                                               $data['title'] = $saved_title;
+                                               $item["body"] = $saved_body;
+                                       }
 
-                               $data_text = strip_tags(trim($data['text'] ?? ''));
-                               $item_body = strip_tags(trim($item['body'] ?? ''));
+                                       $data_text = strip_tags(trim($data['text'] ?? ''));
+                                       $item_body = strip_tags(trim($item['body'] ?? ''));
 
-                               if (!empty($data_text) && (($data_text == $item_body) || strstr($item_body, $data_text))) {
-                                       $data['text'] = '';
-                               }
+                                       if (!empty($data_text) && (($data_text == $item_body) || strstr($item_body, $data_text))) {
+                                               $data['text'] = '';
+                                       }
 
-                               // We always strip the title since it will be added in the page information
-                               $item["title"] = "";
-                               $item["body"] = $item["body"] . "\n" . PageInfo::getFooterFromData($data, false);
-                               $taglist = $contact["fetch_further_information"] == 2 ? PageInfo::getTagsFromUrl($item["plink"], $preview, $contact["ffi_keyword_denylist"] ?? '') : [];
-                               $item["object-type"] = Activity\ObjectType::BOOKMARK;
-                               $attachments = [];
+                                       // We always strip the title since it will be added in the page information
+                                       $item["title"] = "";
+                                       $item["body"] = $item["body"] . "\n" . PageInfo::getFooterFromData($data, false);
+                                       $taglist = $contact["fetch_further_information"] == 2 ? PageInfo::getTagsFromUrl($item["plink"], $preview, $contact["ffi_keyword_denylist"] ?? '') : [];
+                                       $item["object-type"] = Activity\ObjectType::BOOKMARK;
+                                       $attachments = [];
+                               }
                        } else {
                                if (!empty($summary)) {
                                        $item["body"] = '[abstract]' . HTML::toBBCode($summary, $basepath) . "[/abstract]\n" . $item["body"];