diff --git a/src/Factory/Api/Mastodon/Attachment.php b/src/Factory/Api/Mastodon/Attachment.php index ae0ebf1826..52361284ac 100644 --- a/src/Factory/Api/Mastodon/Attachment.php +++ b/src/Factory/Api/Mastodon/Attachment.php @@ -11,7 +11,7 @@ use Friendica\App\BaseURL; use Friendica\BaseFactory; use Friendica\Model\Attach; use Friendica\Model\Photo; -use Friendica\Network\HTTPException; +use Friendica\Network\HTTPException\InternalServerErrorException; use Friendica\Model\Post; use Friendica\Util\Images; use Friendica\Util\Proxy; @@ -32,7 +32,7 @@ class Attachment extends BaseFactory /** * @param int $uriId Uri-ID of the attachments * @return array - * @throws HTTPException\InternalServerErrorException + * @throws InternalServerErrorException */ public function createFromUriId(int $uriId): array { @@ -47,21 +47,30 @@ class Attachment extends BaseFactory /** * @param int $id id of the media * @return \Friendica\Object\Api\Mastodon\Attachment - * @throws HTTPException\InternalServerErrorException + * @throws InternalServerErrorException */ public function createFromId(int $id): \Friendica\Object\Api\Mastodon\Attachment { $attachment = Post\Media::getById($id); + if (empty($attachment)) { - return []; + $attachment = [ + 'id' => '', + 'description' => '', + 'url' => '', + 'mimetype' => '', + 'blurhash' => '', + 'type' => Post\Media::UNKNOWN, + ]; } + return $this->createFromMediaArray($attachment); } /** * @param array $attachment * @return \Friendica\Object\Api\Mastodon\Attachment - * @throws HTTPException\InternalServerErrorException + * @throws InternalServerErrorException */ private function createFromMediaArray(array $attachment): \Friendica\Object\Api\Mastodon\Attachment { @@ -100,7 +109,7 @@ class Attachment extends BaseFactory * @param int $id id of the photo * * @return array - * @throws HTTPException\InternalServerErrorException + * @throws InternalServerErrorException */ public function createFromPhoto(int $id): array { @@ -136,7 +145,7 @@ class Attachment extends BaseFactory * @param int $id id of the attachment * * @return array - * @throws HTTPException\InternalServerErrorException + * @throws InternalServerErrorException */ public function createFromAttach(int $id): array { diff --git a/src/Factory/Api/Twitter/Status.php b/src/Factory/Api/Twitter/Status.php index b31a89fc44..c83b0aa9ab 100644 --- a/src/Factory/Api/Twitter/Status.php +++ b/src/Factory/Api/Twitter/Status.php @@ -39,7 +39,7 @@ class Status extends BaseFactory private $mention; /** @var Activities entity */ private $activities; - /** @var Activities entity */ + /** @var Attachment entity */ private $attachment; /** @var ContentItem */ private $contentItem; diff --git a/src/Federation/Repository/GServer.php b/src/Federation/Repository/GServer.php index 5a12f3339b..8e9c7e9449 100644 --- a/src/Federation/Repository/GServer.php +++ b/src/Federation/Repository/GServer.php @@ -28,6 +28,8 @@ class GServer extends \Friendica\BaseRepository */ public function selectOneById(int $gsid): Entity\GServer { - return $this->_selectOne(['id' => $gsid]); + $fields = $this->_selectFirstRowAsArray( ['id' => $gsid]); + + return $this->factory->createFromTableRow($fields); } } diff --git a/src/Model/Contact/User.php b/src/Model/Contact/User.php index 17663e233b..aa85013811 100644 --- a/src/Model/Contact/User.php +++ b/src/Model/Contact/User.php @@ -30,9 +30,8 @@ class User * Insert a user-contact for a given contact array * * @param array $contact - * @return void */ - public static function insertForContactArray(array $contact) + public static function insertForContactArray(array $contact): bool { if (empty($contact['uid'])) { // We don't create entries for the public user - by now @@ -339,7 +338,7 @@ class User { $pcid = Contact::getPublicContactId($cid, $uid); if (!$pcid) { - return false; + return self::FREQUENCY_DEFAULT; } $public_contact = DBA::selectFirst('user-contact', ['channel-frequency'], ['cid' => $pcid, 'uid' => $uid]); diff --git a/src/Model/Event.php b/src/Model/Event.php index 6cb73f4c37..39aba01efd 100644 --- a/src/Model/Event.php +++ b/src/Model/Event.php @@ -305,7 +305,7 @@ class Event Hook::callAll("event_created", $event['id']); } - return $event['id']; + return (int) $event['id']; } public static function getItemArrayForId(int $event_id, array $item = []): array diff --git a/src/Model/GServer.php b/src/Model/GServer.php index 7029adbb53..8ead599408 100644 --- a/src/Model/GServer.php +++ b/src/Model/GServer.php @@ -2200,8 +2200,6 @@ class GServer * Converts input value to a boolean value * * @param string|integer $val - * - * @return boolean */ private static function toBoolean($val): bool { @@ -2211,7 +2209,7 @@ class GServer return false; } - return $val; + return (bool) $val; } /**