From 9523927b8e77b53be557d533b6995fba87ac4650 Mon Sep 17 00:00:00 2001 From: Diogo Peralta Cordeiro Date: Fri, 18 Feb 2022 15:28:48 +0000 Subject: [PATCH] [PLUGIN][ActivityPub][Model][Note] There may be no attachments, nor tags, nor to, nor cc --- plugins/ActivityPub/Util/Model/ActivityCreate.php | 4 ++-- plugins/ActivityPub/Util/Model/Note.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/ActivityPub/Util/Model/ActivityCreate.php b/plugins/ActivityPub/Util/Model/ActivityCreate.php index abc934b410..84b72475a5 100644 --- a/plugins/ActivityPub/Util/Model/ActivityCreate.php +++ b/plugins/ActivityPub/Util/Model/ActivityCreate.php @@ -55,12 +55,12 @@ class ActivityCreate extends Activity if ($type_object->get('type') === 'Note' || $type_object->get('type') === 'Page') { $actual_to = array_flip(is_string($type_object->get('to')) ? [$type_object->get('to')] : $type_object->get('to')); $actual_cc = array_flip(is_string($type_object->get('cc')) ? [$type_object->get('cc')] : $type_object->get('cc')); - foreach (is_string($type_activity->get('to')) ? [$type_activity->get('to')] : $type_activity->get('to') as $to) { + foreach (is_string($type_activity->get('to')) ? [$type_activity->get('to')] : ($type_activity->get('to') ?? []) as $to) { if ($to !== 'https://www.w3.org/ns/activitystreams#Public') { $actual_to[$to] = true; } } - foreach (is_string($type_activity->get('cc')) ? [$type_activity->get('cc')] : $type_activity->get('cc') as $cc) { + foreach (is_string($type_activity->get('cc')) ? [$type_activity->get('cc')] : ($type_activity->get('cc') ?? []) as $cc) { if ($cc !== 'https://www.w3.org/ns/activitystreams#Public') { $actual_cc[$cc] = true; } diff --git a/plugins/ActivityPub/Util/Model/Note.php b/plugins/ActivityPub/Util/Model/Note.php index e8ccbda5d9..6a74fddb2e 100644 --- a/plugins/ActivityPub/Util/Model/Note.php +++ b/plugins/ActivityPub/Util/Model/Note.php @@ -224,7 +224,7 @@ class Note extends Model // Attachments $processed_attachments = []; - foreach ($type_note->get('attachment') as $attachment) { + foreach ($type_note->get('attachment') ?? [] as $attachment) { if ($attachment->get('type') === 'Document') { // Retrieve media $get_response = HTTPClient::get($attachment->get('url')); @@ -253,7 +253,7 @@ class Note extends Model // Assign conversation to this note Conversation::assignLocalConversation($obj, $reply_to); - foreach ($type_note->get('tag') as $ap_tag) { + foreach ($type_note->get('tag') ?? [] as $ap_tag) { switch ($ap_tag->get('type')) { case 'Mention': case 'Group':