Changed parameter order for getByURL

This commit is contained in:
Michael 2020-07-15 17:06:48 +00:00
parent d9c6a46ffe
commit fc0312451d
22 changed files with 32 additions and 32 deletions

View File

@ -145,7 +145,7 @@ function undo_post_tagging($s) {
if ($cnt) { if ($cnt) {
foreach ($matches as $mtch) { foreach ($matches as $mtch) {
if (in_array($mtch[1], ['!', '@'])) { if (in_array($mtch[1], ['!', '@'])) {
$contact = Contact::getByURL($mtch[2], 0, ['addr'], false); $contact = Contact::getByURL($mtch[2], false, ['addr']);
$mtch[3] = empty($contact['addr']) ? $mtch[2] : $contact['addr']; $mtch[3] = empty($contact['addr']) ? $mtch[2] : $contact['addr'];
} }
$s = str_replace($mtch[0], $mtch[1] . $mtch[3],$s); $s = str_replace($mtch[0], $mtch[1] . $mtch[3],$s);

View File

@ -107,7 +107,7 @@ function follow_content(App $a)
} }
} }
$contact = Contact::getByURL($url, 0, [], true); $contact = Contact::getByURL($url, true);
if (empty($contact)) { if (empty($contact)) {
// Possibly it is a remote item and not an account // Possibly it is a remote item and not an account
follow_remote_item($url); follow_remote_item($url);

View File

@ -102,7 +102,7 @@ function match_content(App $a)
'follow' => [DI::l10n()->t("Connect/Follow"), $connlnk] 'follow' => [DI::l10n()->t("Connect/Follow"), $connlnk]
]; ];
$contact_details = Contact::getByURL($profile->url, 0, [], false); $contact_details = Contact::getByURL($profile->url, false);
$entry = [ $entry = [
'url' => Contact::magicLink($profile->url), 'url' => Contact::magicLink($profile->url),

View File

@ -396,7 +396,7 @@ function message_content(App $a)
$body_e = BBCode::convert($message['body']); $body_e = BBCode::convert($message['body']);
$to_name_e = $message['name']; $to_name_e = $message['name'];
$contact = Contact::getByURL($message['from-url'], 0, ['thumb', 'addr'], false); $contact = Contact::getByURL($message['from-url'], false, ['thumb', 'addr']);
if (isset($contact["thumb"])) { if (isset($contact["thumb"])) {
$from_photo = $contact["thumb"]; $from_photo = $contact["thumb"];
} else { } else {
@ -528,7 +528,7 @@ function render_messages(array $msg, $t)
$body_e = $rr['body']; $body_e = $rr['body'];
$to_name_e = $rr['name']; $to_name_e = $rr['name'];
$contact = Contact::getByURL($rr['url'], 0, ['thumb', 'addr'], false); $contact = Contact::getByURL($rr['url'], false, ['thumb', 'addr']);
if (isset($contact["thumb"])) { if (isset($contact["thumb"])) {
$from_photo = $contact["thumb"]; $from_photo = $contact["thumb"];
} else { } else {

View File

@ -331,7 +331,7 @@ function ping_init(App $a)
if (DBA::isResult($notifs)) { if (DBA::isResult($notifs)) {
foreach ($notifs as $notif) { foreach ($notifs as $notif) {
$contact = Contact::getByURL($notif['url'], 0, ['micro'], false); $contact = Contact::getByURL($notif['url'], false, ['micro']);
if (isset($contact['micro'])) { if (isset($contact['micro'])) {
$notif['photo'] = ProxyUtils::proxifyUrl($contact['micro'], false, ProxyUtils::SIZE_MICRO); $notif['photo'] = ProxyUtils::proxifyUrl($contact['micro'], false, ProxyUtils::SIZE_MICRO);
} else { } else {

View File

@ -146,7 +146,7 @@ function unfollow_content(App $a)
]); ]);
DI::page()['aside'] = ''; DI::page()['aside'] = '';
Profile::load($a, '', Contact::getByURL($contact['url'], 0, [], false)); Profile::load($a, '', Contact::getByURL($contact['url'], false));
$o .= Renderer::replaceMacros(Renderer::getMarkupTemplate('section_title.tpl'), ['$title' => DI::l10n()->t('Status Messages and Posts')]); $o .= Renderer::replaceMacros(Renderer::getMarkupTemplate('section_title.tpl'), ['$title' => DI::l10n()->t('Status Messages and Posts')]);

View File

@ -130,7 +130,7 @@ class Item
// Checking for the alias that is used for OStatus // Checking for the alias that is used for OStatus
$pattern = '/[@!]\[url\=(.*?)\](.*?)\[\/url\]/ism'; $pattern = '/[@!]\[url\=(.*?)\](.*?)\[\/url\]/ism';
if (preg_match($pattern, $tag, $matches)) { if (preg_match($pattern, $tag, $matches)) {
$data = Contact::getByURL($matches[1], 0, ['alias', 'nick'], false); $data = Contact::getByURL($matches[1], false, ['alias', 'nick']);
if ($data['alias'] != '') { if ($data['alias'] != '') {
$newtag = '@[url=' . $data['alias'] . ']' . $data['nick'] . '[/url]'; $newtag = '@[url=' . $data['alias'] . ']' . $data['nick'] . '[/url]';

View File

@ -983,7 +983,7 @@ class BBCode
$attributes[$field] = html_entity_decode($matches[2] ?? '', ENT_QUOTES, 'UTF-8'); $attributes[$field] = html_entity_decode($matches[2] ?? '', ENT_QUOTES, 'UTF-8');
} }
$author_contact = Contact::getByURL($attributes['profile'], 0, ['url', 'addr', 'name', 'micro'], false); $author_contact = Contact::getByURL($attributes['profile'], false, ['url', 'addr', 'name', 'micro']);
$author_contact['url'] = ($author_contact['url'] ?? $attributes['profile']); $author_contact['url'] = ($author_contact['url'] ?? $attributes['profile']);
$author_contact['addr'] = ($author_contact['addr'] ?? '') ?: Protocol::getAddrFromProfileUrl($attributes['profile']); $author_contact['addr'] = ($author_contact['addr'] ?? '') ?: Protocol::getAddrFromProfileUrl($attributes['profile']);
@ -1061,7 +1061,7 @@ class BBCode
default: default:
$text = ($is_quote_share? "\n" : ''); $text = ($is_quote_share? "\n" : '');
$contact = Contact::getByURL($attributes['profile'], 0, ['network'], false); $contact = Contact::getByURL($attributes['profile'], false, ['network']);
$network = $contact['network'] ?? Protocol::PHANTOM; $network = $contact['network'] ?? Protocol::PHANTOM;
$tpl = Renderer::getMarkupTemplate('shared_content.tpl'); $tpl = Renderer::getMarkupTemplate('shared_content.tpl');
@ -1975,7 +1975,7 @@ class BBCode
*/ */
private static function bbCodeMention2DiasporaCallback($match) private static function bbCodeMention2DiasporaCallback($match)
{ {
$contact = Contact::getByURL($match[3], 0, ['addr']); $contact = Contact::getByURL($match[3], null, ['addr']);
if (empty($contact['addr'])) { if (empty($contact['addr'])) {
return $match[0]; return $match[0];

View File

@ -213,7 +213,7 @@ class Introduction extends BaseFactory
// If the network and addr is still not available // If the network and addr is still not available
// get the missing data data from other sources // get the missing data data from other sources
if (empty($intro['gnetwork']) || empty($intro['gaddr'])) { if (empty($intro['gnetwork']) || empty($intro['gaddr'])) {
$ret = Contact::getByURL($intro['url'], 0, ['network', 'addr'], false); $ret = Contact::getByURL($intro['url'], false, ['network', 'addr']);
if (empty($intro['gnetwork']) && !empty($ret['network'])) { if (empty($intro['gnetwork']) && !empty($ret['network'])) {
$intro['gnetwork'] = $ret['network']; $intro['gnetwork'] = $ret['network'];

View File

@ -199,7 +199,7 @@ class Contact
* @param boolean $update true = always update, false = never update, null = update when not found or outdated * @param boolean $update true = always update, false = never update, null = update when not found or outdated
* @return array contact array * @return array contact array
*/ */
public static function getByURL(string $url, int $uid = 0, array $fields = [], $update = null) public static function getByURL(string $url, $update = null, array $fields = [], int $uid = 0)
{ {
if ($update || is_null($update)) { if ($update || is_null($update)) {
$cid = self::getIdForURL($url, $uid, !($update ?? false)); $cid = self::getIdForURL($url, $uid, !($update ?? false));
@ -241,7 +241,7 @@ class Contact
public static function getByURLForUser(string $url, int $uid = 0, array $fields = [], $update = null) public static function getByURLForUser(string $url, int $uid = 0, array $fields = [], $update = null)
{ {
if ($uid != 0) { if ($uid != 0) {
$contact = self::getByURL($url, $uid, $fields, $update); $contact = self::getByURL($url, $update, $fields, $uid);
if (!empty($contact)) { if (!empty($contact)) {
if (!empty($contact['id'])) { if (!empty($contact['id'])) {
$contact['cid'] = $contact['id']; $contact['cid'] = $contact['id'];
@ -251,7 +251,7 @@ class Contact
} }
} }
$contact = self::getByURL($url, 0, $fields, $update); $contact = self::getByURL($url, $update, $fields);
if (!empty($contact['id'])) { if (!empty($contact['id'])) {
$contact['cid'] = 0; $contact['cid'] = 0;
$contact['zid'] = $contact['id']; $contact['zid'] = $contact['id'];
@ -1318,7 +1318,7 @@ class Contact
return 0; return 0;
} }
$contact = self::getByURL($url, $uid, ['id', 'avatar', 'updated', 'network'], false); $contact = self::getByURL($url, false, ['id', 'avatar', 'updated', 'network'], $uid);
if (!empty($contact)) { if (!empty($contact)) {
$contact_id = $contact["id"]; $contact_id = $contact["id"];

View File

@ -63,7 +63,7 @@ class AllFriends extends BaseModule
} }
DI::page()['aside'] = ""; DI::page()['aside'] = "";
Model\Profile::load($app, "", Model\Contact::getByURL($contact["url"], 0, [], false)); Model\Profile::load($app, "", Model\Contact::getByURL($contact["url"], false));
$total = Model\GContact::countAllFriends(local_user(), $cid); $total = Model\GContact::countAllFriends(local_user(), $cid);

View File

@ -971,7 +971,7 @@ class Contact extends BaseModule
if (DBA::isResult($contact)) { if (DBA::isResult($contact)) {
DI::page()['aside'] = ''; DI::page()['aside'] = '';
$profiledata = Model\Contact::getByURL($contact['url'], 0, [], false); $profiledata = Model\Contact::getByURL($contact['url'], false);
Model\Profile::load($a, '', $profiledata, true); Model\Profile::load($a, '', $profiledata, true);
@ -994,7 +994,7 @@ class Contact extends BaseModule
if (DBA::isResult($contact)) { if (DBA::isResult($contact)) {
DI::page()['aside'] = ''; DI::page()['aside'] = '';
$profiledata = Model\Contact::getByURL($contact['url'], 0, [], false); $profiledata = Model\Contact::getByURL($contact['url'], false);
if (local_user() && in_array($profiledata['network'], Protocol::FEDERATED)) { if (local_user() && in_array($profiledata['network'], Protocol::FEDERATED)) {
$profiledata['remoteconnect'] = DI::baseUrl() . '/follow?url=' . urlencode($profiledata['url']); $profiledata['remoteconnect'] = DI::baseUrl() . '/follow?url=' . urlencode($profiledata['url']);

View File

@ -108,7 +108,7 @@ class Advanced extends BaseModule
throw new BadRequestException(DI::l10n()->t('Contact not found.')); throw new BadRequestException(DI::l10n()->t('Contact not found.'));
} }
Model\Profile::load(DI::app(), "", Model\Contact::getByURL($contact["url"], 0, [], false)); Model\Profile::load(DI::app(), "", Model\Contact::getByURL($contact["url"], false));
$warning = DI::l10n()->t('<strong>WARNING: This is highly advanced</strong> and if you enter incorrect information your communications with this contact may stop working.'); $warning = DI::l10n()->t('<strong>WARNING: This is highly advanced</strong> and if you enter incorrect information your communications with this contact may stop working.');
$info = DI::l10n()->t('Please use your browser \'Back\' button <strong>now</strong> if you are uncertain what to do on this page.'); $info = DI::l10n()->t('Please use your browser \'Back\' button <strong>now</strong> if you are uncertain what to do on this page.');

View File

@ -67,7 +67,7 @@ class Hovercard extends BaseModule
if (Session::isAuthenticated()) { if (Session::isAuthenticated()) {
$contact = Contact::getByURLForUser($contact_url, local_user(), [], false); $contact = Contact::getByURLForUser($contact_url, local_user(), [], false);
} else { } else {
$contact = Contact::getByURL($contact_url, 0, [], false); $contact = Contact::getByURL($contact_url, false);
} }
if (!count($contact)) { if (!count($contact)) {

View File

@ -138,7 +138,7 @@ class Poke extends BaseModule
throw new HTTPException\NotFoundException(); throw new HTTPException\NotFoundException();
} }
Model\Profile::load(DI::app(), '', Model\Contact::getByURL($contact["url"], 0, [], false)); Model\Profile::load(DI::app(), '', Model\Contact::getByURL($contact["url"], false));
$verbs = []; $verbs = [];
foreach (DI::l10n()->getPokeVerbs() as $verb => $translations) { foreach (DI::l10n()->getPokeVerbs() as $verb => $translations) {

View File

@ -350,7 +350,7 @@ class Acl extends BaseModule
continue; continue;
} }
$contact = Contact::getByURL($author, 0, ['micro', 'name', 'id', 'network', 'nick', 'addr', 'url', 'forum'], false); $contact = Contact::getByURL($author, false, ['micro', 'name', 'id', 'network', 'nick', 'addr', 'url', 'forum']);
if (count($contact) > 0) { if (count($contact) > 0) {
$unknown_contacts[] = [ $unknown_contacts[] = [

View File

@ -239,7 +239,7 @@ class Index extends BaseSearch
if ($isAddr) { if ($isAddr) {
$contact = Contact::selectFirst(['id'], ['addr' => $search, 'uid' => 0]); $contact = Contact::selectFirst(['id'], ['addr' => $search, 'uid' => 0]);
} else { } else {
$contact = array_merge(['id' => 0], Contact::getByURL($search, 0, ['id'])); $contact = array_merge(['id' => 0], Contact::getByURL($search, null, ['id']));
} }
if (DBA::isResult($contact)) { if (DBA::isResult($contact)) {

View File

@ -877,7 +877,7 @@ class Post
$terms = Tag::getByURIId($item['uri-id'], [Tag::MENTION, Tag::IMPLICIT_MENTION, Tag::EXCLUSIVE_MENTION]); $terms = Tag::getByURIId($item['uri-id'], [Tag::MENTION, Tag::IMPLICIT_MENTION, Tag::EXCLUSIVE_MENTION]);
foreach ($terms as $term) { foreach ($terms as $term) {
$profile = Contact::getByURL($term['url'], 0, ['addr', 'contact-type'], false); $profile = Contact::getByURL($term['url'], false, ['addr', 'contact-type']);
if (!empty($profile['addr']) && ((($profile['contact-type'] ?? '') ?: Contact::TYPE_UNKNOWN) != Contact::TYPE_COMMUNITY) && if (!empty($profile['addr']) && ((($profile['contact-type'] ?? '') ?: Contact::TYPE_UNKNOWN) != Contact::TYPE_COMMUNITY) &&
($profile['addr'] != $owner['addr']) && !strstr($text, $profile['addr'])) { ($profile['addr'] != $owner['addr']) && !strstr($text, $profile['addr'])) {
$text .= '@' . $profile['addr'] . ' '; $text .= '@' . $profile['addr'] . ' ';

View File

@ -987,7 +987,7 @@ class Processor
{ {
$parent_terms = Tag::getByURIId($parent['uri-id'], [Tag::MENTION, Tag::IMPLICIT_MENTION, Tag::EXCLUSIVE_MENTION]); $parent_terms = Tag::getByURIId($parent['uri-id'], [Tag::MENTION, Tag::IMPLICIT_MENTION, Tag::EXCLUSIVE_MENTION]);
$parent_author = Contact::getByURL($parent['author-link'], 0, ['url', 'nurl', 'alias'], false); $parent_author = Contact::getByURL($parent['author-link'], false, ['url', 'nurl', 'alias']);
$implicit_mentions = []; $implicit_mentions = [];
if (empty($parent_author['url'])) { if (empty($parent_author['url'])) {
@ -1003,7 +1003,7 @@ class Processor
} }
foreach ($parent_terms as $term) { foreach ($parent_terms as $term) {
$contact = Contact::getByURL($term['url'], 0, ['url', 'nurl', 'alias'], false); $contact = Contact::getByURL($term['url'], false, ['url', 'nurl', 'alias']);
if (!empty($contact['url'])) { if (!empty($contact['url'])) {
$implicit_mentions[] = $contact['url']; $implicit_mentions[] = $contact['url'];
$implicit_mentions[] = $contact['nurl']; $implicit_mentions[] = $contact['nurl'];

View File

@ -1008,7 +1008,7 @@ class Transmitter
$url = DI::baseUrl() . '/search?tag=' . urlencode($term['name']); $url = DI::baseUrl() . '/search?tag=' . urlencode($term['name']);
$tags[] = ['type' => 'Hashtag', 'href' => $url, 'name' => '#' . $term['name']]; $tags[] = ['type' => 'Hashtag', 'href' => $url, 'name' => '#' . $term['name']];
} else { } else {
$contact = Contact::getByURL($term['url'], 0, ['addr'], false); $contact = Contact::getByURL($term['url'], false, ['addr']);
if (!empty($contact['addr'])) { if (!empty($contact['addr'])) {
$mention = '@' . $contact['addr']; $mention = '@' . $contact['addr'];
} else { } else {
@ -1141,7 +1141,7 @@ class Transmitter
return ''; return '';
} }
$data = Contact::getByURL($match[1], 0, ['url', 'nick'], false); $data = Contact::getByURL($match[1], false, ['url', 'nick']);
if (empty($data['nick'])) { if (empty($data['nick'])) {
return $match[0]; return $match[0];
} }
@ -1861,7 +1861,7 @@ class Transmitter
$mentions = []; $mentions = [];
foreach (Tag::getByURIId($uriid, [Tag::IMPLICIT_MENTION]) as $tag) { foreach (Tag::getByURIId($uriid, [Tag::IMPLICIT_MENTION]) as $tag) {
$profile = Contact::getByURL($tag['url'], 0, ['addr', 'contact-type', 'nick'], false); $profile = Contact::getByURL($tag['url'], false, ['addr', 'contact-type', 'nick']);
if (!empty($profile['addr']) if (!empty($profile['addr'])
&& $profile['contact-type'] != Contact::TYPE_COMMUNITY && $profile['contact-type'] != Contact::TYPE_COMMUNITY
&& !strstr($body, $profile['addr']) && !strstr($body, $profile['addr'])

View File

@ -3729,7 +3729,7 @@ class Diaspora
private static function prependParentAuthorMention($body, $profile_url) private static function prependParentAuthorMention($body, $profile_url)
{ {
$profile = Contact::getByURL($profile_url, 0, ['addr', 'name', 'contact-type'], false); $profile = Contact::getByURL($profile_url, false, ['addr', 'name', 'contact-type']);
if (!empty($profile['addr']) if (!empty($profile['addr'])
&& $profile['contact-type'] != Contact::TYPE_COMMUNITY && $profile['contact-type'] != Contact::TYPE_COMMUNITY
&& !strstr($body, $profile['addr']) && !strstr($body, $profile['addr'])

View File

@ -2105,7 +2105,7 @@ class OStatus
$mentioned = $newmentions; $mentioned = $newmentions;
foreach ($mentioned as $mention) { foreach ($mentioned as $mention) {
$contact = Contact::getByURL($mention, 0, ['contact-type']); $contact = Contact::getByURL($mention, ['contact-type']);
if (!empty($contact) && ($contact['contact-type'] == Contact::TYPE_COMMUNITY)) { if (!empty($contact) && ($contact['contact-type'] == Contact::TYPE_COMMUNITY)) {
XML::addElement($doc, $entry, "link", "", XML::addElement($doc, $entry, "link", "",
[ [