From: Roland Häder Date: Mon, 20 Jun 2022 17:04:01 +0000 (+0200) Subject: Changes: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=4fb03cf1632dd41a91cbfdf70207fd253fb7f9d2;p=friendica.git Changes: - fixed a null value handled over to Friendica\Model\APContact::getByURL() - added missing type-hints --- diff --git a/src/Model/Item.php b/src/Model/Item.php index 1e3326e285..5144e73e0e 100644 --- a/src/Model/Item.php +++ b/src/Model/Item.php @@ -1841,13 +1841,13 @@ class Item $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(); } diff --git a/src/Protocol/ActivityPub/Receiver.php b/src/Protocol/ActivityPub/Receiver.php index be1c3b7e7c..29f6b5bec7 100644 --- a/src/Protocol/ActivityPub/Receiver.php +++ b/src/Protocol/ActivityPub/Receiver.php @@ -80,13 +80,12 @@ class Receiver /** * Checks incoming message from the inbox * - * @param $body - * @param $header + * @param string $body Body string + * @param array $header Header lines * @param integer $uid User ID * @throws \Exception - * @todo Find type for $body/$header */ - public static function processInbox($body, $header, int $uid) + public static function processInbox(string $body, array $header, int $uid) { $activity = json_decode($body, true); if (empty($activity)) { @@ -98,7 +97,7 @@ class Receiver $actor = JsonLD::fetchElement($ldactivity, 'as:actor', '@id'); - $apcontact = APContact::getByURL($actor); + $apcontact = APContact::getByURL($actor ?? ''); if (empty($apcontact)) { Logger::notice('Unable to retrieve AP contact for actor - message is discarded', ['actor' => $actor]); return;