Fix errors in Model namespace

This commit is contained in:
Art4 2024-12-03 22:46:40 +00:00
parent 06e3051ad1
commit 2c801abb06
6 changed files with 99 additions and 105 deletions

View file

@ -12,11 +12,11 @@ use Friendica\Database\DBA;
use Friendica\DI; use Friendica\DI;
use Friendica\Core\Storage\Exception\InvalidClassStorageException; use Friendica\Core\Storage\Exception\InvalidClassStorageException;
use Friendica\Core\Storage\Exception\ReferenceStorageException; use Friendica\Core\Storage\Exception\ReferenceStorageException;
use Friendica\Network\HTTPException\InternalServerErrorException;
use Friendica\Object\Image; use Friendica\Object\Image;
use Friendica\Util\DateTimeFormat; use Friendica\Util\DateTimeFormat;
use Friendica\Util\Mimetype; use Friendica\Util\Mimetype;
use Friendica\Security\Security; use Friendica\Security\Security;
use Friendica\Util\Network;
/** /**
* Class to handle attach database table * Class to handle attach database table
@ -183,7 +183,7 @@ class Attach
* @param string $deny_gid Permissions, denied circle. optional, default = '' * @param string $deny_gid Permissions, denied circle. optional, default = ''
* *
* @return boolean|integer Row id on success, False on errors * @return boolean|integer Row id on success, False on errors
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws InternalServerErrorException
*/ */
public static function store(string $data, int $uid, string $filename, string $filetype = '', int $filesize = null, string $allow_cid = '', string $allow_gid = '', string $deny_cid = '', string $deny_gid = '') public static function store(string $data, int $uid, string $filename, string $filetype = '', int $filesize = null, string $allow_cid = '', string $allow_gid = '', string $deny_cid = '', string $deny_gid = '')
{ {
@ -237,7 +237,7 @@ class Attach
* @param string $deny_cid * @param string $deny_cid
* @param string $deny_gid * @param string $deny_gid
* @return boolean|int Insert id or false on failure * @return boolean|int Insert id or false on failure
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws InternalServerErrorException
*/ */
public static function storeFile(string $src, int $uid, string $filename = '', string $filetype = '', string $allow_cid = '', string $allow_gid = '', string $deny_cid = '', string $deny_gid = '') public static function storeFile(string $src, int $uid, string $filename = '', string $filetype = '', string $allow_cid = '', string $allow_gid = '', string $deny_cid = '', string $deny_gid = '')
{ {
@ -257,11 +257,11 @@ class Attach
* @param array $fields Contains the fields that are updated * @param array $fields Contains the fields that are updated
* @param array $conditions Condition array with the key values * @param array $conditions Condition array with the key values
* @param Image $img Image data to update. Optional, default null. * @param Image $img Image data to update. Optional, default null.
* @param array|boolean $old_fields Array with the old field values that are about to be replaced (true = update on duplicate) * @param array $old_fields Array with the old field values that are about to be replaced (true = update on duplicate)
* *
* @return boolean Was the update successful? * @return boolean Was the update successful?
* *
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws InternalServerErrorException
* @see \Friendica\Database\DBA::update * @see \Friendica\Database\DBA::update
*/ */
public static function update(array $fields, array $conditions, Image $img = null, array $old_fields = []): bool public static function update(array $fields, array $conditions, Image $img = null, array $old_fields = []): bool
@ -287,12 +287,10 @@ class Attach
return DBA::update('attach', $fields, $conditions, $old_fields); return DBA::update('attach', $fields, $conditions, $old_fields);
} }
/** /**
* Delete info from table and data from storage * Delete info from table and data from storage
* *
* @param array $conditions Field condition(s) * @param array $conditions Field condition(s)
* @param array $options Options array, Optional
* *
* @return boolean * @return boolean
* *

View file

@ -7,10 +7,10 @@
namespace Friendica\Model; namespace Friendica\Model;
use Exception;
use Friendica\Contact\Avatar; use Friendica\Contact\Avatar;
use Friendica\Contact\Header; use Friendica\Contact\Header;
use Friendica\Contact\Introduction\Exception\IntroductionNotFoundException; use Friendica\Contact\Introduction\Exception\IntroductionNotFoundException;
use Friendica\Contact\LocalRelationship\Entity\LocalRelationship;
use Friendica\Content\Conversation as ConversationContent; use Friendica\Content\Conversation as ConversationContent;
use Friendica\Content\Pager; use Friendica\Content\Pager;
use Friendica\Content\Text\HTML; use Friendica\Content\Text\HTML;
@ -25,7 +25,8 @@ use Friendica\Database\DBA;
use Friendica\DI; use Friendica\DI;
use Friendica\Network\HTTPClient\Client\HttpClientAccept; use Friendica\Network\HTTPClient\Client\HttpClientAccept;
use Friendica\Network\HTTPClient\Client\HttpClientOptions; use Friendica\Network\HTTPClient\Client\HttpClientOptions;
use Friendica\Network\HTTPException; use Friendica\Network\HTTPException\NotFoundException;
use Friendica\Network\HTTPException\InternalServerErrorException;
use Friendica\Network\Probe; use Friendica\Network\Probe;
use Friendica\Object\Image; use Friendica\Object\Image;
use Friendica\Protocol\Activity; use Friendica\Protocol\Activity;
@ -104,7 +105,7 @@ class Contact
* @param array $condition Array of fields for condition * @param array $condition Array of fields for condition
* @param array $params Array of several parameters * @param array $params Array of several parameters
* @return array * @return array
* @throws \Exception * @throws Exception
*/ */
public static function selectToArray(array $fields = [], array $condition = [], array $params = []): array public static function selectToArray(array $fields = [], array $condition = [], array $params = []): array
{ {
@ -116,7 +117,7 @@ class Contact
* @param array $condition Array of fields for condition * @param array $condition Array of fields for condition
* @param array $params Array of several parameters * @param array $params Array of several parameters
* @return array|bool * @return array|bool
* @throws \Exception * @throws Exception
*/ */
public static function selectFirst(array $fields = [], array $condition = [], array $params = []) public static function selectFirst(array $fields = [], array $condition = [], array $params = [])
{ {
@ -130,7 +131,7 @@ class Contact
* @param array $condition Array of fields for condition * @param array $condition Array of fields for condition
* @param array $params Array of several parameters * @param array $params Array of several parameters
* @return array * @return array
* @throws \Exception * @throws Exception
*/ */
public static function selectAccountToArray(array $fields = [], array $condition = [], array $params = []): array public static function selectAccountToArray(array $fields = [], array $condition = [], array $params = []): array
{ {
@ -142,7 +143,7 @@ class Contact
* @param array $condition Array of fields for condition * @param array $condition Array of fields for condition
* @param array $params Array of several parameters * @param array $params Array of several parameters
* @return array|bool * @return array|bool
* @throws \Exception * @throws Exception
*/ */
public static function selectFirstAccount(array $fields = [], array $condition = [], array $params = []) public static function selectFirstAccount(array $fields = [], array $condition = [], array $params = [])
{ {
@ -162,7 +163,7 @@ class Contact
* @param int $duplicate_mode Do an update on a duplicate entry * @param int $duplicate_mode Do an update on a duplicate entry
* *
* @return int id of the created contact * @return int id of the created contact
* @throws \Exception * @throws Exception
*/ */
public static function insert(array $fields, int $duplicate_mode = Database::INSERT_DEFAULT): int public static function insert(array $fields, int $duplicate_mode = Database::INSERT_DEFAULT): int
{ {
@ -233,7 +234,7 @@ class Contact
* @param array|boolean $old_fields array with the old field values that are about to be replaced (true = update on duplicate, false = don't update identical fields) * @param array|boolean $old_fields array with the old field values that are about to be replaced (true = update on duplicate, false = don't update identical fields)
* *
* @return boolean was the update successful? * @return boolean was the update successful?
* @throws \Exception * @throws Exception
* @todo Let's get rid of boolean type of $old_fields * @todo Let's get rid of boolean type of $old_fields
*/ */
public static function update(array $fields, array $condition, $old_fields = []): bool public static function update(array $fields, array $condition, $old_fields = []): bool
@ -249,7 +250,7 @@ class Contact
* @param integer $id Contact ID * @param integer $id Contact ID
* @param array $fields Array of selected fields, empty for all * @param array $fields Array of selected fields, empty for all
* @return array|boolean Contact record if it exists, false otherwise * @return array|boolean Contact record if it exists, false otherwise
* @throws \Exception * @throws Exception
*/ */
public static function getAccountById(int $id, array $fields = []) public static function getAccountById(int $id, array $fields = [])
{ {
@ -260,7 +261,7 @@ class Contact
* @param integer $id Contact ID * @param integer $id Contact ID
* @param array $fields Array of selected fields, empty for all * @param array $fields Array of selected fields, empty for all
* @return array|boolean Contact record if it exists, false otherwise * @return array|boolean Contact record if it exists, false otherwise
* @throws \Exception * @throws Exception
*/ */
public static function getById(int $id, array $fields = []) public static function getById(int $id, array $fields = [])
{ {
@ -273,7 +274,7 @@ class Contact
* @param integer $uri_id uri-id of the contact * @param integer $uri_id uri-id of the contact
* @param array $fields Array of selected fields, empty for all * @param array $fields Array of selected fields, empty for all
* @return array|boolean Contact record if it exists, false otherwise * @return array|boolean Contact record if it exists, false otherwise
* @throws \Exception * @throws Exception
*/ */
public static function getByUriId(int $uri_id, array $fields = []) public static function getByUriId(int $uri_id, array $fields = [])
{ {
@ -288,7 +289,7 @@ class Contact
* *
* @return array all remote contacts * @return array all remote contacts
* *
* @throws \Exception * @throws Exception
*/ */
public static function getVisitorByUrl(string $url, array $fields = ['id', 'uid']): array public static function getVisitorByUrl(string $url, array $fields = ['id', 'uid']): array
{ {
@ -432,7 +433,7 @@ class Contact
* @param bool $strict If "true" then contact mustn't be set to pending or readonly * @param bool $strict If "true" then contact mustn't be set to pending or readonly
* *
* @return boolean is the contact id a follower? * @return boolean is the contact id a follower?
* @throws HTTPException\InternalServerErrorException * @throws InternalServerErrorException
* @throws \ImagickException * @throws \ImagickException
*/ */
public static function isFollower(int $cid, int $uid, bool $strict = false): bool public static function isFollower(int $cid, int $uid, bool $strict = false): bool
@ -461,7 +462,7 @@ class Contact
* @param bool $strict If "true" then contact mustn't be set to pending or readonly * @param bool $strict If "true" then contact mustn't be set to pending or readonly
* *
* @return boolean is the contact id a follower? * @return boolean is the contact id a follower?
* @throws HTTPException\InternalServerErrorException * @throws InternalServerErrorException
* @throws \ImagickException * @throws \ImagickException
*/ */
public static function isFollowerByURL(string $url, int $uid, bool $strict = false): bool public static function isFollowerByURL(string $url, int $uid, bool $strict = false): bool
@ -483,7 +484,7 @@ class Contact
* @param bool $strict If "true" then contact mustn't be set to pending or readonly * @param bool $strict If "true" then contact mustn't be set to pending or readonly
* *
* @return boolean is the contact sharing with given user? * @return boolean is the contact sharing with given user?
* @throws HTTPException\InternalServerErrorException * @throws InternalServerErrorException
* @throws \ImagickException * @throws \ImagickException
*/ */
public static function isSharing(int $cid, int $uid, bool $strict = false): bool public static function isSharing(int $cid, int $uid, bool $strict = false): bool
@ -512,7 +513,7 @@ class Contact
* @param bool $strict If "true" then contact mustn't be set to pending or readonly * @param bool $strict If "true" then contact mustn't be set to pending or readonly
* *
* @return boolean is the contact url being followed? * @return boolean is the contact url being followed?
* @throws HTTPException\InternalServerErrorException * @throws InternalServerErrorException
* @throws \ImagickException * @throws \ImagickException
*/ */
public static function isSharingByURL(string $url, int $uid, bool $strict = false): bool public static function isSharingByURL(string $url, int $uid, bool $strict = false): bool
@ -544,7 +545,7 @@ class Contact
* @param boolean $dont_update Don't update the contact * @param boolean $dont_update Don't update the contact
* *
* @return string basepath * @return string basepath
* @throws HTTPException\InternalServerErrorException * @throws InternalServerErrorException
* @throws \ImagickException * @throws \ImagickException
*/ */
public static function getBasepath(string $url, bool $dont_update = false): string public static function getBasepath(string $url, bool $dont_update = false): string
@ -594,7 +595,7 @@ class Contact
/** /**
* Check if the given contact ID is on the same server * Check if the given contact ID is on the same server
* *
* @param string $url The contact link * @param int $cid The contact link
* @return boolean Is it the same server? * @return boolean Is it the same server?
*/ */
public static function isLocalById(int $cid): bool public static function isLocalById(int $cid): bool
@ -619,7 +620,7 @@ class Contact
* @param integer $uid User ID * @param integer $uid User ID
* *
* @return integer|boolean Public contact id for given user id * @return integer|boolean Public contact id for given user id
* @throws \Exception * @throws Exception
*/ */
public static function getPublicIdByUserId(int $uid) public static function getPublicIdByUserId(int $uid)
{ {
@ -634,7 +635,7 @@ class Contact
* @param int $uid User ID * @param int $uid User ID
* *
* @return array with public and user's contact id * @return array with public and user's contact id
* @throws HTTPException\InternalServerErrorException * @throws InternalServerErrorException
* @throws \ImagickException * @throws \ImagickException
*/ */
public static function getPublicAndUserContactID(int $cid, int $uid): array public static function getPublicAndUserContactID(int $cid, int $uid): array
@ -700,7 +701,7 @@ class Contact
* @param int $cid Either public contact id or user's contact id * @param int $cid Either public contact id or user's contact id
* @param int $uid User ID * @param int $uid User ID
* @return array with public and user's contact id * @return array with public and user's contact id
* @throws HTTPException\InternalServerErrorException * @throws InternalServerErrorException
* @throws \ImagickException * @throws \ImagickException
*/ */
private static function legacyGetPublicAndUserContactID(int $cid, int $uid): array private static function legacyGetPublicAndUserContactID(int $cid, int $uid): array
@ -741,7 +742,7 @@ class Contact
* @param array $fields The selected fields for the contact * @param array $fields The selected fields for the contact
* @return array The contact details * @return array The contact details
* *
* @throws \Exception * @throws Exception
*/ */
public static function getContactForUser(int $cid, int $uid, array $fields = []): array public static function getContactForUser(int $cid, int $uid, array $fields = []): array
{ {
@ -759,7 +760,7 @@ class Contact
* *
* @param int $uid * @param int $uid
* @return bool Operation success * @return bool Operation success
* @throws HTTPException\InternalServerErrorException * @throws InternalServerErrorException
*/ */
public static function createSelfFromUserId(int $uid): bool public static function createSelfFromUserId(int $uid): bool
{ {
@ -822,7 +823,7 @@ class Contact
* @param int $uid * @param int $uid
* @param bool $update_avatar Force the avatar update * @param bool $update_avatar Force the avatar update
* @return bool "true" if updated * @return bool "true" if updated
* @throws \Exception * @throws Exception
*/ */
public static function updateSelfFromUserID(int $uid, bool $update_avatar = false): bool public static function updateSelfFromUserID(int $uid, bool $update_avatar = false): bool
{ {
@ -943,7 +944,7 @@ class Contact
* *
* @param int $id contact id * @param int $id contact id
* @return void * @return void
* @throws HTTPException\InternalServerErrorException * @throws InternalServerErrorException
*/ */
public static function remove(int $id) public static function remove(int $id)
{ {
@ -973,7 +974,7 @@ class Contact
* *
* @param array $contact Target user-specific contact (uid != 0) array * @param array $contact Target user-specific contact (uid != 0) array
* @return void * @return void
* @throws HTTPException\InternalServerErrorException * @throws InternalServerErrorException
* @throws \ImagickException * @throws \ImagickException
*/ */
public static function unfollow(array $contact): void public static function unfollow(array $contact): void
@ -1003,7 +1004,7 @@ class Contact
* *
* @param array $contact User-specific contact array (uid != 0) to revoke the follow from * @param array $contact User-specific contact array (uid != 0) to revoke the follow from
* @return void * @return void
* @throws HTTPException\InternalServerErrorException * @throws InternalServerErrorException
* @throws \ImagickException * @throws \ImagickException
*/ */
public static function revokeFollow(array $contact): void public static function revokeFollow(array $contact): void
@ -1031,7 +1032,7 @@ class Contact
* *
* @param array $contact User-specific contact (uid != 0) array * @param array $contact User-specific contact (uid != 0) array
* @return void * @return void
* @throws HTTPException\InternalServerErrorException * @throws InternalServerErrorException
* @throws \ImagickException * @throws \ImagickException
*/ */
public static function terminateFriendship(array $contact) public static function terminateFriendship(array $contact)
@ -1078,7 +1079,7 @@ class Contact
* *
* @param array $contact contact to mark for archival * @param array $contact contact to mark for archival
* @return void * @return void
* @throws HTTPException\InternalServerErrorException * @throws InternalServerErrorException
*/ */
public static function markForArchival(array $contact) public static function markForArchival(array $contact)
{ {
@ -1129,7 +1130,7 @@ class Contact
* *
* @param array $contact contact to be unmarked for archival * @param array $contact contact to be unmarked for archival
* @return void * @return void
* @throws \Exception * @throws Exception
*/ */
public static function unmarkForArchival(array $contact) public static function unmarkForArchival(array $contact)
{ {
@ -1169,7 +1170,7 @@ class Contact
* @param array $contact contact * @param array $contact contact
* @param int $uid Visitor user id * @param int $uid Visitor user id
* @return array * @return array
* @throws HTTPException\InternalServerErrorException * @throws InternalServerErrorException
* @throws \ImagickException * @throws \ImagickException
*/ */
public static function photoMenu(array $contact, int $uid): array public static function photoMenu(array $contact, int $uid): array
@ -1301,7 +1302,7 @@ class Contact
* @param array $default Default value for creating the contact when everything else fails * @param array $default Default value for creating the contact when everything else fails
* *
* @return integer Contact ID * @return integer Contact ID
* @throws HTTPException\InternalServerErrorException * @throws InternalServerErrorException
* @throws \ImagickException * @throws \ImagickException
*/ */
public static function getIdForURL(string $url = null, int $uid = 0, $update = null, array $default = []): int public static function getIdForURL(string $url = null, int $uid = 0, $update = null, array $default = []): int
@ -1442,7 +1443,7 @@ class Contact
if ($data['network'] == Protocol::DIASPORA) { if ($data['network'] == Protocol::DIASPORA) {
try { try {
DI::dsprContact()->updateFromProbeArray($data); DI::dsprContact()->updateFromProbeArray($data);
} catch (HTTPException\NotFoundException $e) { } catch (NotFoundException $e) {
Logger::notice($e->getMessage(), ['url' => $url, 'data' => $data]); Logger::notice($e->getMessage(), ['url' => $url, 'data' => $data]);
} catch (\InvalidArgumentException $e) { } catch (\InvalidArgumentException $e) {
Logger::notice($e->getMessage(), ['url' => $url, 'data' => $data]); Logger::notice($e->getMessage(), ['url' => $url, 'data' => $data]);
@ -1450,7 +1451,7 @@ class Contact
} elseif (!empty($data['networks'][Protocol::DIASPORA])) { } elseif (!empty($data['networks'][Protocol::DIASPORA])) {
try { try {
DI::dsprContact()->updateFromProbeArray($data['networks'][Protocol::DIASPORA]); DI::dsprContact()->updateFromProbeArray($data['networks'][Protocol::DIASPORA]);
} catch (HTTPException\NotFoundException $e) { } catch (NotFoundException $e) {
Logger::notice($e->getMessage(), ['url' => $url, 'data' => $data['networks'][Protocol::DIASPORA]]); Logger::notice($e->getMessage(), ['url' => $url, 'data' => $data['networks'][Protocol::DIASPORA]]);
} catch (\InvalidArgumentException $e) { } catch (\InvalidArgumentException $e) {
Logger::notice($e->getMessage(), ['url' => $url, 'data' => $data['networks'][Protocol::DIASPORA]]); Logger::notice($e->getMessage(), ['url' => $url, 'data' => $data['networks'][Protocol::DIASPORA]]);
@ -1475,7 +1476,7 @@ class Contact
* @param int $cid contact id * @param int $cid contact id
* *
* @return boolean Is the contact archived? * @return boolean Is the contact archived?
* @throws HTTPException\InternalServerErrorException * @throws InternalServerErrorException
*/ */
public static function isArchived(int $cid): bool public static function isArchived(int $cid): bool
{ {
@ -1518,7 +1519,7 @@ class Contact
* *
* @param int $cid contact id * @param int $cid contact id
* @return boolean Is the contact blocked? * @return boolean Is the contact blocked?
* @throws HTTPException\InternalServerErrorException * @throws InternalServerErrorException
*/ */
public static function isBlocked(int $cid): bool public static function isBlocked(int $cid): bool
{ {
@ -1543,7 +1544,7 @@ class Contact
* *
* @param int $cid contact id * @param int $cid contact id
* @return boolean Is the contact hidden? * @return boolean Is the contact hidden?
* @throws \Exception * @throws Exception
*/ */
public static function isHidden(int $cid): bool public static function isHidden(int $cid): bool
{ {
@ -1566,7 +1567,7 @@ class Contact
* @param bool $only_media Only display media content * @param bool $only_media Only display media content
* @param string $last_created Newest creation date, used for paging * @param string $last_created Newest creation date, used for paging
* @return string posts in HTML * @return string posts in HTML
* @throws \Exception * @throws Exception
*/ */
public static function getPostsFromUrl(string $contact_url, int $uid, bool $only_media = false, string $last_created = null): string public static function getPostsFromUrl(string $contact_url, int $uid, bool $only_media = false, string $last_created = null): string
{ {
@ -1581,7 +1582,7 @@ class Contact
* @param bool $only_media Only display media content * @param bool $only_media Only display media content
* @param string $last_created Newest creation date, used for paging * @param string $last_created Newest creation date, used for paging
* @return string posts in HTML * @return string posts in HTML
* @throws \Exception * @throws Exception
*/ */
public static function getPostsFromId(int $cid, int $uid, bool $only_media = false, string $last_created = null): string public static function getPostsFromId(int $cid, int $uid, bool $only_media = false, string $last_created = null): string
{ {
@ -1653,7 +1654,7 @@ class Contact
* @param int $update Update mode * @param int $update Update mode
* @param int $parent Item parent ID for the update mode * @param int $parent Item parent ID for the update mode
* @return string posts in HTML * @return string posts in HTML
* @throws \Exception * @throws Exception
*/ */
public static function getThreadsFromId(int $cid, int $uid, int $update = 0, int $parent = 0, string $last_created = ''): string public static function getThreadsFromId(int $cid, int $uid, int $update = 0, int $parent = 0, string $last_created = ''): string
{ {
@ -2286,8 +2287,8 @@ class Contact
* @param bool $create_cache Enforces the creation of cached avatar fields * @param bool $create_cache Enforces the creation of cached avatar fields
* *
* @return void * @return void
* @throws HTTPException\InternalServerErrorException * @throws InternalServerErrorException
* @throws HTTPException\NotFoundException * @throws NotFoundException
* @throws \ImagickException * @throws \ImagickException
*/ */
public static function updateAvatar(int $cid, string $avatar, bool $force = false, bool $create_cache = false) public static function updateAvatar(int $cid, string $avatar, bool $force = false, bool $create_cache = false)
@ -2486,7 +2487,7 @@ class Contact
* @param integer $id contact id * @param integer $id contact id
* @param string $url The new URL to use for polling * @param string $url The new URL to use for polling
* *
* @throws \Exception * @throws Exception
*/ */
public static function updatePollUrl(int $id, string $url) public static function updatePollUrl(int $id, string $url)
{ {
@ -2502,7 +2503,7 @@ class Contact
* @param string $url The profile URL of the contact * @param string $url The profile URL of the contact
* @param array $fields The fields that are updated * @param array $fields The fields that are updated
* *
* @throws \Exception * @throws Exception
*/ */
private static function updateContact(int $id, int $uid, int $uri_id, string $url, array $fields) private static function updateContact(int $id, int $uid, int $uri_id, string $url, array $fields)
{ {
@ -2595,7 +2596,7 @@ class Contact
* @param string $nurl Normalised contact url * @param string $nurl Normalised contact url
* @param integer $uid User id * @param integer $uid User id
* @return boolean * @return boolean
* @throws \Exception * @throws Exception
*/ */
public static function removeDuplicates(string $nurl, int $uid) public static function removeDuplicates(string $nurl, int $uid)
{ {
@ -2673,7 +2674,7 @@ class Contact
* @param integer $id contact id * @param integer $id contact id
* @param string $network Optional network we are probing for * @param string $network Optional network we are probing for
* @return boolean * @return boolean
* @throws HTTPException\InternalServerErrorException * @throws InternalServerErrorException
* @throws \ImagickException * @throws \ImagickException
*/ */
public static function updateFromProbe(int $id, string $network = ''): bool public static function updateFromProbe(int $id, string $network = ''): bool
@ -2696,7 +2697,7 @@ class Contact
if ($data['network'] == Protocol::DIASPORA) { if ($data['network'] == Protocol::DIASPORA) {
try { try {
DI::dsprContact()->updateFromProbeArray($data); DI::dsprContact()->updateFromProbeArray($data);
} catch (HTTPException\NotFoundException $e) { } catch (NotFoundException $e) {
Logger::notice($e->getMessage(), ['id' => $id, 'network' => $network, 'contact' => $contact, 'data' => $data]); Logger::notice($e->getMessage(), ['id' => $id, 'network' => $network, 'contact' => $contact, 'data' => $data]);
} catch (\InvalidArgumentException $e) { } catch (\InvalidArgumentException $e) {
Logger::notice($e->getMessage(), ['id' => $id, 'network' => $network, 'contact' => $contact, 'data' => $data]); Logger::notice($e->getMessage(), ['id' => $id, 'network' => $network, 'contact' => $contact, 'data' => $data]);
@ -2704,7 +2705,7 @@ class Contact
} elseif (!empty($data['networks'][Protocol::DIASPORA])) { } elseif (!empty($data['networks'][Protocol::DIASPORA])) {
try { try {
DI::dsprContact()->updateFromProbeArray($data['networks'][Protocol::DIASPORA]); DI::dsprContact()->updateFromProbeArray($data['networks'][Protocol::DIASPORA]);
} catch (HTTPException\NotFoundException $e) { } catch (NotFoundException $e) {
Logger::notice($e->getMessage(), ['id' => $id, 'network' => $network, 'contact' => $contact, 'data' => $data]); Logger::notice($e->getMessage(), ['id' => $id, 'network' => $network, 'contact' => $contact, 'data' => $data]);
} catch (\InvalidArgumentException $e) { } catch (\InvalidArgumentException $e) {
Logger::notice($e->getMessage(), ['id' => $id, 'network' => $network, 'contact' => $contact, 'data' => $data]); Logger::notice($e->getMessage(), ['id' => $id, 'network' => $network, 'contact' => $contact, 'data' => $data]);
@ -2760,7 +2761,7 @@ class Contact
* @param integer $id contact id * @param integer $id contact id
* @param array $ret Probed data * @param array $ret Probed data
* @return boolean * @return boolean
* @throws HTTPException\InternalServerErrorException * @throws InternalServerErrorException
* @throws \ImagickException * @throws \ImagickException
*/ */
private static function updateFromProbeArray(int $id, array $ret): bool private static function updateFromProbeArray(int $id, array $ret): bool
@ -3012,9 +3013,9 @@ class Contact
/** /**
* Updates contact record by provided URL * Updates contact record by provided URL
* *
* @param integer $url contact url * @param string $url contact url
* @return integer Contact id * @return int Contact id
* @throws HTTPException\InternalServerErrorException * @throws InternalServerErrorException
* @throws \ImagickException * @throws \ImagickException
*/ */
public static function updateFromProbeByURL(string $url): int public static function updateFromProbeByURL(string $url): int
@ -3069,8 +3070,8 @@ class Contact
* @param string $url The profile URL of the contact * @param string $url The profile URL of the contact
* @param string $network * @param string $network
* @return array * @return array
* @throws HTTPException\InternalServerErrorException * @throws InternalServerErrorException
* @throws HTTPException\NotFoundException * @throws NotFoundException
* @throws \ImagickException * @throws \ImagickException
*/ */
public static function createFromProbeForUser(int $uid, string $url, string $network = ''): array public static function createFromProbeForUser(int $uid, string $url, string $network = ''): array
@ -3258,7 +3259,7 @@ class Contact
* @param bool $sharing True: Contact is now sharing with Owner; False: Contact is now following Owner (default) * @param bool $sharing True: Contact is now sharing with Owner; False: Contact is now following Owner (default)
* @param string $note Introduction additional message * @param string $note Introduction additional message
* @return bool|null True: follow request is accepted; False: relationship is rejected; Null: relationship is pending * @return bool|null True: follow request is accepted; False: relationship is rejected; Null: relationship is pending
* @throws HTTPException\InternalServerErrorException * @throws InternalServerErrorException
* @throws \ImagickException * @throws \ImagickException
*/ */
public static function addRelationship(array $importer, array $contact, array $datarray, bool $sharing = false, string $note = '') public static function addRelationship(array $importer, array $contact, array $datarray, bool $sharing = false, string $note = '')
@ -3415,7 +3416,7 @@ class Contact
* @param array $contact User-specific contact (uid != 0) array * @param array $contact User-specific contact (uid != 0) array
* @param bool $delete Delete if set, otherwise set relation to "nothing" when contact had been a follower * @param bool $delete Delete if set, otherwise set relation to "nothing" when contact had been a follower
* @return void * @return void
* @throws HTTPException\InternalServerErrorException * @throws InternalServerErrorException
* @throws \ImagickException * @throws \ImagickException
*/ */
public static function removeFollower(array $contact, bool $delete = true) public static function removeFollower(array $contact, bool $delete = true)
@ -3449,7 +3450,7 @@ class Contact
* *
* @param array $contact User-specific contact (uid != 0) array * @param array $contact User-specific contact (uid != 0) array
* @param bool $delete Delete if set, otherwise set relation to "nothing" when contact had been a sharer * @param bool $delete Delete if set, otherwise set relation to "nothing" when contact had been a sharer
* @throws HTTPException\InternalServerErrorException * @throws InternalServerErrorException
*/ */
public static function removeSharer(array $contact, bool $delete = true) public static function removeSharer(array $contact, bool $delete = true)
{ {
@ -3512,7 +3513,7 @@ class Contact
* *
* @param array $contact_ids Contact id list * @param array $contact_ids Contact id list
* @return array * @return array
* @throws \Exception * @throws Exception
*/ */
public static function pruneUnavailable(array $contact_ids): array public static function pruneUnavailable(array $contact_ids): array
{ {
@ -3554,7 +3555,7 @@ class Contact
* @param string $url An url that we will be redirected to after the authentication * @param string $url An url that we will be redirected to after the authentication
* *
* @return string with "redir" link * @return string with "redir" link
* @throws HTTPException\InternalServerErrorException * @throws InternalServerErrorException
* @throws \ImagickException * @throws \ImagickException
*/ */
public static function magicLink(string $contact_url, string $url = ''): string public static function magicLink(string $contact_url, string $url = ''): string
@ -3581,7 +3582,7 @@ class Contact
* @param string $url An url that we will be redirected to after the authentication * @param string $url An url that we will be redirected to after the authentication
* *
* @return string with "redir" link * @return string with "redir" link
* @throws HTTPException\InternalServerErrorException * @throws InternalServerErrorException
* @throws \ImagickException * @throws \ImagickException
*/ */
public static function magicLinkById(int $cid, string $url = ''): string public static function magicLinkById(int $cid, string $url = ''): string
@ -3605,7 +3606,7 @@ class Contact
* @param string $url An url that we will be redirected to after the authentication * @param string $url An url that we will be redirected to after the authentication
* *
* @return string with "redir" link * @return string with "redir" link
* @throws HTTPException\InternalServerErrorException * @throws InternalServerErrorException
* @throws \ImagickException * @throws \ImagickException
*/ */
public static function magicLinkByContact(array $contact, string $url = ''): string public static function magicLinkByContact(array $contact, string $url = ''): string
@ -3810,7 +3811,7 @@ class Contact
* @param array $condition * @param array $condition
* *
* @return bool * @return bool
* @throws \Exception * @throws Exception
*/ */
public static function exists(array $condition): bool public static function exists(array $condition): bool
{ {

View file

@ -15,6 +15,7 @@ use Friendica\Database\DBA;
use Friendica\DI; use Friendica\DI;
use Friendica\Model\Contact; use Friendica\Model\Contact;
use Friendica\Model\ItemURI; use Friendica\Model\ItemURI;
use Friendica\Network\HTTPException\InternalServerErrorException;
use PDOException; use PDOException;
/** /**
@ -130,7 +131,7 @@ class User
* @param boolean $blocked Is the contact blocked or unblocked? * @param boolean $blocked Is the contact blocked or unblocked?
* @param boolean $only_set Only set the block flag, don't execute any block transmission * @param boolean $only_set Only set the block flag, don't execute any block transmission
* @return void * @return void
* @throws \Exception * @throws Exception
*/ */
public static function setBlocked(int $cid, int $uid, bool $blocked, bool $only_set = false) public static function setBlocked(int $cid, int $uid, bool $blocked, bool $only_set = false)
{ {
@ -171,7 +172,7 @@ class User
* @param int $uid User ID * @param int $uid User ID
* *
* @return boolean is the contact id blocked for the given user? * @return boolean is the contact id blocked for the given user?
* @throws \Exception * @throws Exception
*/ */
public static function isBlocked(int $cid, int $uid): bool public static function isBlocked(int $cid, int $uid): bool
{ {
@ -212,7 +213,7 @@ class User
* @param int $uid User ID * @param int $uid User ID
* @param boolean $ignored Is the contact ignored or unignored? * @param boolean $ignored Is the contact ignored or unignored?
* @return void * @return void
* @throws \Exception * @throws Exception
*/ */
public static function setIgnored(int $cid, int $uid, bool $ignored) public static function setIgnored(int $cid, int $uid, bool $ignored)
{ {
@ -234,7 +235,7 @@ class User
* @param int $cid Either public contact id or user's contact id * @param int $cid Either public contact id or user's contact id
* @param int $uid User ID * @param int $uid User ID
* @return boolean is the contact id ignored for the given user? * @return boolean is the contact id ignored for the given user?
* @throws \Exception * @throws Exception
*/ */
public static function isIgnored(int $cid, int $uid): bool public static function isIgnored(int $cid, int $uid): bool
{ {
@ -275,7 +276,7 @@ class User
* @param int $uid User ID * @param int $uid User ID
* @param boolean $collapsed are the contact's posts collapsed or uncollapsed? * @param boolean $collapsed are the contact's posts collapsed or uncollapsed?
* @return void * @return void
* @throws \Exception * @throws Exception
*/ */
public static function setCollapsed(int $cid, int $uid, bool $collapsed) public static function setCollapsed(int $cid, int $uid, bool $collapsed)
{ {
@ -293,7 +294,7 @@ class User
* @param int $cid Either public contact id or user's contact id * @param int $cid Either public contact id or user's contact id
* @param int $uid User ID * @param int $uid User ID
* @return boolean is the contact id blocked for the given user? * @return boolean is the contact id blocked for the given user?
* @throws HTTPException\InternalServerErrorException * @throws InternalServerErrorException
* @throws \ImagickException * @throws \ImagickException
*/ */
public static function isCollapsed(int $cid, int $uid): bool public static function isCollapsed(int $cid, int $uid): bool
@ -314,7 +315,7 @@ class User
* @param int $uid User ID * @param int $uid User ID
* @param int $frequency Type of post frequency in channels * @param int $frequency Type of post frequency in channels
* @return void * @return void
* @throws \Exception * @throws Exception
*/ */
public static function setChannelFrequency(int $cid, int $uid, int $frequency) public static function setChannelFrequency(int $cid, int $uid, int $frequency)
{ {
@ -332,7 +333,7 @@ class User
* @param int $cid Either public contact id or user's contact id * @param int $cid Either public contact id or user's contact id
* @param int $uid User ID * @param int $uid User ID
* @return int Type of post frequency in channels * @return int Type of post frequency in channels
* @throws HTTPException\InternalServerErrorException * @throws InternalServerErrorException
* @throws \ImagickException * @throws \ImagickException
*/ */
public static function getChannelFrequency(int $cid, int $uid): int public static function getChannelFrequency(int $cid, int $uid): int
@ -349,11 +350,11 @@ class User
/** /**
* Set the channel only value for contact id and user id * Set the channel only value for contact id and user id
* *
* @param int $cid Either public contact id or user's contact id * @param int $cid Either public contact id or user's contact id
* @param int $uid User ID * @param int $uid User ID
* @param int $isChannelOnly Is channel only * @param bool $isChannelOnly Is channel only
* @return void * @return void
* @throws \Exception * @throws Exception
*/ */
public static function setChannelOnly(int $cid, int $uid, bool $isChannelOnly) public static function setChannelOnly(int $cid, int $uid, bool $isChannelOnly)
{ {
@ -371,7 +372,7 @@ class User
* @param int $cid Either public contact id or user's contact id * @param int $cid Either public contact id or user's contact id
* @param int $uid User ID * @param int $uid User ID
* @return bool Contact is channel only * @return bool Contact is channel only
* @throws HTTPException\InternalServerErrorException * @throws InternalServerErrorException
* @throws \ImagickException * @throws \ImagickException
*/ */
public static function getChannelOnly(int $cid, int $uid): bool public static function getChannelOnly(int $cid, int $uid): bool
@ -392,7 +393,7 @@ class User
* @param int $uid User ID * @param int $uid User ID
* @param boolean $blocked Is the user blocked or unblocked by the contact? * @param boolean $blocked Is the user blocked or unblocked by the contact?
* @return void * @return void
* @throws \Exception * @throws Exception
*/ */
public static function setIsBlocked(int $cid, int $uid, bool $blocked) public static function setIsBlocked(int $cid, int $uid, bool $blocked)
{ {
@ -410,7 +411,7 @@ class User
* @param int $cid Either public contact id or user's contact id * @param int $cid Either public contact id or user's contact id
* @param int $uid User ID * @param int $uid User ID
* @return boolean Is the user blocked or unblocked by the contact? * @return boolean Is the user blocked or unblocked by the contact?
* @throws \Exception * @throws Exception
*/ */
public static function isIsBlocked(int $cid, int $uid): bool public static function isIsBlocked(int $cid, int $uid): bool
{ {

View file

@ -15,7 +15,9 @@ use Friendica\Core\Renderer;
use Friendica\Core\System; use Friendica\Core\System;
use Friendica\Database\DBA; use Friendica\Database\DBA;
use Friendica\DI; use Friendica\DI;
use Friendica\Network\HTTPException; use Friendica\Network\HTTPException\InternalServerErrorException;
use Friendica\Network\HTTPException\NotFoundException;
use Friendica\Network\HTTPException\UnauthorizedException;
use Friendica\Protocol\Activity; use Friendica\Protocol\Activity;
use Friendica\Util\DateTimeFormat; use Friendica\Util\DateTimeFormat;
use Friendica\Util\Map; use Friendica\Util\Map;
@ -487,23 +489,23 @@ class Event
* @param string $nickname * @param string $nickname
* *
* @return array the owner array * @return array the owner array
* @throws HTTPException\InternalServerErrorException * @throws InternalServerErrorException
* @throws HTTPException\NotFoundException The given nickname does not exist * @throws NotFoundException The given nickname does not exist
* @throws HTTPException\UnauthorizedException The access for the given nickname is restricted * @throws UnauthorizedException The access for the given nickname is restricted
*/ */
public static function getOwnerForNickname(string $nickname): array public static function getOwnerForNickname(string $nickname): array
{ {
$owner = User::getOwnerDataByNick($nickname); $owner = User::getOwnerDataByNick($nickname);
if (empty($owner) || $owner['account_removed'] || $owner['account_expired']) { if (empty($owner) || $owner['account_removed'] || $owner['account_expired']) {
throw new HTTPException\NotFoundException(DI::l10n()->t('User not found.')); throw new NotFoundException(DI::l10n()->t('User not found.'));
} }
if (!DI::userSession()->isAuthenticated() && $owner['hidewall']) { if (!DI::userSession()->isAuthenticated() && $owner['hidewall']) {
throw new HTTPException\UnauthorizedException(DI::l10n()->t('Access to this profile has been restricted.')); throw new UnauthorizedException(DI::l10n()->t('Access to this profile has been restricted.'));
} }
if (!DI::userSession()->isAuthenticated() && !Feature::isEnabled($owner['uid'], Feature::PUBLIC_CALENDAR)) { if (!DI::userSession()->isAuthenticated() && !Feature::isEnabled($owner['uid'], Feature::PUBLIC_CALENDAR)) {
throw new HTTPException\UnauthorizedException(DI::l10n()->t('Permission denied.')); throw new UnauthorizedException(DI::l10n()->t('Permission denied.'));
} }
return $owner; return $owner;
@ -514,7 +516,6 @@ class Event
* *
* @param int $owner_uid The User ID of the owner of the event * @param int $owner_uid The User ID of the owner of the event
* @param int $event_id The ID of the event in the event table * @param int $event_id The ID of the event in the event table
* @param string|null $nickname a possible nickname to search for instead of the owner uid
* @return array Query result * @return array Query result
* @throws \Exception * @throws \Exception
*/ */
@ -541,7 +542,7 @@ class Event
$owner_uid $owner_uid
)); ));
if (empty($events)) { if (empty($events)) {
throw new HTTPException\NotFoundException(DI::l10n()->t('Event not found.')); throw new NotFoundException(DI::l10n()->t('Event not found.'));
} }
return $events[0]; return $events[0];
@ -556,8 +557,8 @@ class Event
* @param bool|null $ignore Filters ignored events (false: unignored events, true: ignored events, null: all events) * @param bool|null $ignore Filters ignored events (false: unignored events, true: ignored events, null: all events)
* *
* @return array Query results. * @return array Query results.
* @throws HTTPException\NotFoundException * @throws NotFoundException
* @throws HTTPException\UnauthorizedException * @throws UnauthorizedException
*/ */
public static function getListByDate(int $owner_uid, string $start = null, string $finish = null, ?bool $ignore = false): array public static function getListByDate(int $owner_uid, string $start = null, string $finish = null, ?bool $ignore = false): array
{ {

View file

@ -163,9 +163,6 @@ class GServer
/** /**
* Checks if the given server array is unreachable for a long time now * Checks if the given server array is unreachable for a long time now
*
* @param integer $gsid
* @return boolean
*/ */
private static function isDefunct(array $gserver): bool private static function isDefunct(array $gserver): bool
{ {
@ -506,7 +503,7 @@ class GServer
* *
* @param UriInterface $dirtyUri * @param UriInterface $dirtyUri
* *
* @return UriInterface cleaned URI * @return string cleaned URI
* @throws Exception * @throws Exception
*/ */
public static function cleanUri(UriInterface $dirtyUri): string public static function cleanUri(UriInterface $dirtyUri): string
@ -1349,8 +1346,6 @@ class GServer
* *
* @see https://github.com/jaywink/nodeinfo2 * @see https://github.com/jaywink/nodeinfo2
* *
* @param string $nodeinfo_url address of the nodeinfo path
*
* @return array Server data * @return array Server data
* *
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \Friendica\Network\HTTPException\InternalServerErrorException
@ -1539,7 +1534,6 @@ class GServer
/** /**
* Fetches server data via an ActivityPub account with url of that server * Fetches server data via an ActivityPub account with url of that server
* *
* @param string $url URL of the given server
* @param array $serverdata array with server data * @param array $serverdata array with server data
* *
* @return array server data * @return array server data

View file

@ -445,7 +445,7 @@ class Item
* Get guid from given item record * Get guid from given item record
* *
* @param array $item Item record * @param array $item Item record
* @param bool Whether to notify (?) * @param bool $notify Whether to notify (?)
* @return string Guid * @return string Guid
*/ */
public static function guid(array $item, bool $notify): string public static function guid(array $item, bool $notify): string
@ -2123,7 +2123,6 @@ class Item
* *
* @param array $item * @param array $item
* @return string detected language * @return string detected language
* @throws \Text_LanguageDetect_Exception
*/ */
private static function getLanguage(array $item): ?string private static function getLanguage(array $item): ?string
{ {
@ -3571,7 +3570,7 @@ class Item
} }
$xpath = new \DOMXPath($dom); $xpath = new \DOMXPath($dom);
/** @var DOMElement $element */ /** @var \DOMElement $element */
foreach ($xpath->query("//img[@class='network-svg']") as $element) { foreach ($xpath->query("//img[@class='network-svg']") as $element) {
$src = $element->getAttributeNode('src')->nodeValue; $src = $element->getAttributeNode('src')->nodeValue;
if ($src == $svg) { if ($src == $svg) {