Merge pull request #7266 from MrPetovan/bug/notices
Add type-hint in ActivityPub\Receiver::fetchObject to catch wrong type coercion
This commit is contained in:
commit
097ecdd106
3 changed files with 6 additions and 3 deletions
|
@ -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];
|
||||
|
|
|
@ -741,11 +741,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');
|
||||
|
@ -791,6 +791,7 @@ class Receiver
|
|||
}
|
||||
|
||||
Logger::log('Unhandled object type: ' . $type, Logger::DEBUG);
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue