X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=inline;f=src%2FModel%2FItem.php;h=bb8080e5fd4f234623d5e90af64b6cb0a9a6df6d;hb=88870d18be53fc38d70e842cdc35c7a1bc703b75;hp=1e3326e285d5aab0fb1d413acfc1b92bdc9b1ea9;hpb=6f1d52cf71ff9c62db6ebf0892f8fe4433b8b214;p=friendica.git diff --git a/src/Model/Item.php b/src/Model/Item.php index 1e3326e285..bb8080e5fd 100644 --- a/src/Model/Item.php +++ b/src/Model/Item.php @@ -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']);