mirror of
https://github.com/friendica/friendica
synced 2024-11-19 00:23:47 +00:00
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 $logger;
|
||||||
private static $server_info = '';
|
private static $server_info = '';
|
||||||
|
/** @var PDO|mysqli */
|
||||||
private static $connection;
|
private static $connection;
|
||||||
private static $driver;
|
private static $driver;
|
||||||
private static $error = false;
|
private static $error = false;
|
||||||
|
@ -496,6 +497,7 @@ class DBA
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @var $stmt mysqli_stmt|PDOStatement */
|
||||||
if (!$stmt = self::$connection->prepare($sql)) {
|
if (!$stmt = self::$connection->prepare($sql)) {
|
||||||
$errorInfo = self::$connection->errorInfo();
|
$errorInfo = self::$connection->errorInfo();
|
||||||
self::$error = $errorInfo[2];
|
self::$error = $errorInfo[2];
|
||||||
|
|
|
@ -741,11 +741,11 @@ class Receiver
|
||||||
* @param boolean $trust_source Do we trust the provided object?
|
* @param boolean $trust_source Do we trust the provided object?
|
||||||
* @param integer $uid User ID for the signature that we use to fetch data
|
* @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 \Friendica\Network\HTTPException\InternalServerErrorException
|
||||||
* @throws \ImagickException
|
* @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.
|
// By fetching the type we check if the object is complete.
|
||||||
$type = JsonLD::fetchElement($object, '@type');
|
$type = JsonLD::fetchElement($object, '@type');
|
||||||
|
@ -791,6 +791,7 @@ class Receiver
|
||||||
}
|
}
|
||||||
|
|
||||||
Logger::log('Unhandled object type: ' . $type, Logger::DEBUG);
|
Logger::log('Unhandled object type: ' . $type, Logger::DEBUG);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -749,7 +749,7 @@ class PortableContact
|
||||||
$friendica = false;
|
$friendica = false;
|
||||||
$gnusocial = 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) {
|
foreach ($nodeinfo['protocols']['inbound'] as $inbound) {
|
||||||
if ($inbound == 'diaspora') {
|
if ($inbound == 'diaspora') {
|
||||||
$diaspora = true;
|
$diaspora = true;
|
||||||
|
|
Loading…
Reference in a new issue