]> git.mxchange.org Git - friendica.git/blobdiff - src/Model/Item.php
Changes:
[friendica.git] / src / Model / Item.php
index 1e3326e285d5aab0fb1d413acfc1b92bdc9b1ea9..bb8080e5fd4f234623d5e90af64b6cb0a9a6df6d 100644 (file)
@@ -1830,24 +1830,24 @@ class Item
         * Posts that are created on this system are using System::createUUID.
         * Received ActivityPub posts are using Processor::getGUIDByURL.
         *
-        * @param string $uri uri of an item entry
-        * @param string $host hostname for the GUID prefix
-        * @return string unique guid
+        * @param string      $uri uri of an item entry
+        * @param string|null $host hostname for the GUID prefix
+        * @return string Unique guid
         */
-       public static function guidFromUri(string $uri, string $host): string
+       public static function guidFromUri(string $uri, string $host = null): string
        {
                // Our regular guid routine is using this kind of prefix as well
                // We have to avoid that different routines could accidentally create the same value
                $parsed = parse_url($uri);
 
                // Remove the scheme to make sure that "https" and "http" doesn't make a difference
-               unset($parsed["scheme"]);
+               unset($parsed['scheme']);
 
                // Glue it together to be able to make a hash from it
-               $host_id = implode("/", $parsed);
+               $host_id = implode('/', $parsed);
 
                // Use a mixture of several hashes to provide some GUID like experience
-               return hash("crc32", $host) . '-'. hash('joaat', $host_id) . '-'. hash('fnv164', $host_id);
+               return hash('crc32', $host) . '-'. hash('joaat', $host_id) . '-'. hash('fnv164', $host_id);
        }
 
        /**
@@ -1859,9 +1859,9 @@ class Item
         * @return string
         * @throws \Friendica\Network\HTTPException\InternalServerErrorException
         */
-       public static function newURI($uid, $guid = "")
+       public static function newURI(int $uid, string $guid = ''): string
        {
-               if ($guid == "") {
+               if ($guid == '') {
                        $guid = System::createUUID();
                }
 
@@ -2831,7 +2831,8 @@ class Item
                        $shared_uri_id = 0;
                        $shared_links = [];
                }
-               $attachments = Post\Media::splitAttachments($item['uri-id'], $item['guid'] ?? '', $shared_links, $item['has-media']);
+
+               $attachments = Post\Media::splitAttachments($item['uri-id'], $item['guid'] ?? '', $shared_links, $item['has-media'] ?? false);
                $item['body'] = self::replaceVisualAttachments($attachments, $item['body'] ?? '');
 
                $item['body'] = preg_replace("/\s*\[attachment .*?\].*?\[\/attachment\]\s*/ism", "\n", $item['body']);