From 41f34c426117b096b97be7ce39722b27b5691b3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roland=20H=C3=A4der?= Date: Sat, 18 Jun 2022 18:30:03 +0200 Subject: [PATCH] Maybe fix for: "Argument 1 passed to Friendica\Model\ItemURI::getIdByURI() must be of the type string, null given, called in Processor.php line 1219" --- src/Model/ItemURI.php | 4 ++++ src/Model/Photo.php | 2 +- src/Protocol/ActivityPub/Processor.php | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Model/ItemURI.php b/src/Model/ItemURI.php index b51ebcb08..020c468d2 100644 --- a/src/Model/ItemURI.php +++ b/src/Model/ItemURI.php @@ -65,6 +65,10 @@ class ItemURI */ public static function getIdByURI(string $uri): int { + if (empty($uri)) { + return 0; + } + // If the URI gets too long we only take the first parts and hope for best $uri = substr($uri, 0, 255); diff --git a/src/Model/Photo.php b/src/Model/Photo.php index b2a815c83..77515b149 100644 --- a/src/Model/Photo.php +++ b/src/Model/Photo.php @@ -321,7 +321,7 @@ class Photo * @param string $filename Filename * @param string $album Album name * @param integer $scale Scale - * @param integer $type Photo type + * @param integer $type Photo type, optional, default: Photo::DEFAULT * @param string $allow_cid Permissions, allowed contacts. optional, default = "" * @param string $allow_gid Permissions, allowed groups. optional, default = "" * @param string $deny_cid Permissions, denied contacts.optional, default = "" diff --git a/src/Protocol/ActivityPub/Processor.php b/src/Protocol/ActivityPub/Processor.php index c2333004f..eab23222c 100644 --- a/src/Protocol/ActivityPub/Processor.php +++ b/src/Protocol/ActivityPub/Processor.php @@ -1216,7 +1216,7 @@ class Processor } $replyto = JsonLD::fetchElement($activity['as:object'], 'as:inReplyTo', '@id'); - $uriid = ItemURI::getIdByURI($replyto); + $uriid = ItemURI::getIdByURI($replyto ?? ''); if (Post::exists(['uri-id' => $uriid])) { Logger::info('Post is a reply to an existing post - accepted', ['id' => $id, 'uri-id' => $uriid, 'replyto' => $replyto]); return true;