From 8035bad8e283b149ea4f70bfd6c1b471a1d9d853 Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 18 Oct 2018 05:54:44 +0000 Subject: [PATCH] AP: Fix a notice / avoid an error when fetched content hadn't been an array --- src/Protocol/ActivityPub.php | 8 +++++++- src/Protocol/ActivityPub/Processor.php | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Protocol/ActivityPub.php b/src/Protocol/ActivityPub.php index 0af8ee5e35..23eb861721 100644 --- a/src/Protocol/ActivityPub.php +++ b/src/Protocol/ActivityPub.php @@ -63,7 +63,13 @@ class ActivityPub return false; } - return json_decode($curlResult->getBody(), true); + $content = json_decode($curlResult->getBody(), true); + + if (empty($content) || !is_array($content)) { + return false; + } + + return $content; } /** diff --git a/src/Protocol/ActivityPub/Processor.php b/src/Protocol/ActivityPub/Processor.php index c481423a67..9bafb5e175 100644 --- a/src/Protocol/ActivityPub/Processor.php +++ b/src/Protocol/ActivityPub/Processor.php @@ -272,7 +272,7 @@ class Processor $activity['cc'] = defaults($object, 'cc', []); $activity['actor'] = $child['author']; $activity['object'] = $object; - $activity['published'] = $object['published']; + $activity['published'] = defaults($object, 'published', $child['published']); $activity['type'] = 'Create'; $ldactivity = JsonLD::compact($activity); -- 2.39.5