]> git.mxchange.org Git - friendica.git/commitdiff
Return early if an URI id cannot be obtained in ActivityPub\Processor::createItem
authorHypolite Petovan <hypolite@mrpetovan.com>
Sun, 13 Dec 2020 18:42:08 +0000 (13:42 -0500)
committerHypolite Petovan <hypolite@mrpetovan.com>
Sun, 13 Dec 2020 18:42:08 +0000 (13:42 -0500)
- Address https://github.com/friendica/friendica/issues/9250#issuecomment-743769813

src/Model/ItemURI.php
src/Protocol/ActivityPub/Processor.php

index 7f05786c8ee72072b5cbe73b2aca26f381a2f91a..6421b2dbd9a5007cafd463ff04d62bc7a0c43043 100644 (file)
@@ -31,10 +31,10 @@ class ItemURI
         *
         * @param array $fields Item-uri fields
         *
-        * @return integer item-uri id
+        * @return int|null item-uri id
         * @throws \Exception
         */
-       public static function insert($fields)
+       public static function insert(array $fields)
        {
                // If the URI gets too long we only take the first parts and hope for best
                $uri = substr($fields['uri'], 0, 255);
index 088a10e90845e34eef8fd9df66a7644adee558e4..f60eea7122211d3aeafa67bbfe50a25bda82e9c0 100644 (file)
@@ -327,6 +327,10 @@ class Processor
                $item['guid'] = $activity['diaspora:guid'] ?: $guid;
 
                $item['uri-id'] = ItemURI::insert(['uri' => $item['uri'], 'guid' => $item['guid']]);
+               if (empty($item['uri-id'])) {
+                       Logger::warning('Unable to get a uri-id for an item uri', ['uri' => $item['uri'], 'guid' => $item['guid']]);
+                       return [];
+               }
 
                $item = self::processContent($activity, $item);
                if (empty($item)) {