From af9ce6b92acde542419e2b5fed7c73f3f7a87472 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Thu, 13 Jun 2019 19:07:04 -0400 Subject: [PATCH 1/3] Add type-hint for dynamic variables in DBA --- src/Database/DBA.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Database/DBA.php b/src/Database/DBA.php index 9f34a86c15..72769dca9b 100644 --- a/src/Database/DBA.php +++ b/src/Database/DBA.php @@ -45,6 +45,7 @@ class DBA */ private static $logger; private static $server_info = ''; + /** @var PDO|mysqli */ private static $connection; private static $driver; private static $error = false; @@ -496,6 +497,7 @@ class DBA break; } + /** @var $stmt mysqli_stmt|PDOStatement */ if (!$stmt = self::$connection->prepare($sql)) { $errorInfo = self::$connection->errorInfo(); self::$error = $errorInfo[2]; From 66d4f1d40bac32fdece001cd734c9ace6cced182 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Thu, 13 Jun 2019 19:07:39 -0400 Subject: [PATCH 2/3] Add type-hint in ActivityPub\Receiver::fetchObject to catch wrong type coercion --- src/Protocol/ActivityPub/Receiver.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Protocol/ActivityPub/Receiver.php b/src/Protocol/ActivityPub/Receiver.php index 97bd7dc7e7..735e412fde 100644 --- a/src/Protocol/ActivityPub/Receiver.php +++ b/src/Protocol/ActivityPub/Receiver.php @@ -736,11 +736,11 @@ class Receiver * @param boolean $trust_source Do we trust the provided object? * @param integer $uid User ID for the signature that we use to fetch data * - * @return array with trusted and valid object data + * @return array|false with trusted and valid object data * @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \ImagickException */ - private static function fetchObject($object_id, $object = [], $trust_source = false, $uid = 0) + private static function fetchObject(string $object_id, array $object = [], bool $trust_source = false, int $uid = 0) { // By fetching the type we check if the object is complete. $type = JsonLD::fetchElement($object, '@type'); @@ -786,6 +786,7 @@ class Receiver } Logger::log('Unhandled object type: ' . $type, Logger::DEBUG); + return false; } /** From 95094aa53d9400cb464f789c2019ad94fe865552 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Fri, 14 Jun 2019 06:25:44 -0400 Subject: [PATCH 3/3] Check for existing protocols.inbound value in Protocol\PortableContact --- src/Protocol/PortableContact.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Protocol/PortableContact.php b/src/Protocol/PortableContact.php index 60bb844226..def8f1b628 100644 --- a/src/Protocol/PortableContact.php +++ b/src/Protocol/PortableContact.php @@ -749,7 +749,7 @@ class PortableContact $friendica = false; $gnusocial = false; - if (is_array($nodeinfo['protocols']['inbound'])) { + if (!empty($nodeinfo['protocols']['inbound']) && is_array($nodeinfo['protocols']['inbound'])) { foreach ($nodeinfo['protocols']['inbound'] as $inbound) { if ($inbound == 'diaspora') { $diaspora = true;