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) {
foreach ($matches as $mtch) {
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'];
}
$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)) {
// Possibly it is a remote item and not an account
follow_remote_item($url);

View File

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

View File

@ -396,7 +396,7 @@ function message_content(App $a)
$body_e = BBCode::convert($message['body']);
$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"])) {
$from_photo = $contact["thumb"];
} else {
@ -528,7 +528,7 @@ function render_messages(array $msg, $t)
$body_e = $rr['body'];
$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"])) {
$from_photo = $contact["thumb"];
} else {

View File

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

View File

@ -146,7 +146,7 @@ function unfollow_content(App $a)
]);
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')]);

View File

@ -130,7 +130,7 @@ class Item
// Checking for the alias that is used for OStatus
$pattern = '/[@!]\[url\=(.*?)\](.*?)\[\/url\]/ism';
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'] != '') {
$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');
}
$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['addr'] = ($author_contact['addr'] ?? '') ?: Protocol::getAddrFromProfileUrl($attributes['profile']);
@ -1061,7 +1061,7 @@ class BBCode
default:
$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;
$tpl = Renderer::getMarkupTemplate('shared_content.tpl');
@ -1975,7 +1975,7 @@ class BBCode
*/
private static function bbCodeMention2DiasporaCallback($match)
{
$contact = Contact::getByURL($match[3], 0, ['addr']);
$contact = Contact::getByURL($match[3], null, ['addr']);
if (empty($contact['addr'])) {
return $match[0];

View File

@ -213,7 +213,7 @@ class Introduction extends BaseFactory
// If the network and addr is still not available
// get the missing data data from other sources
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'])) {
$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
* @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)) {
$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)
{
if ($uid != 0) {
$contact = self::getByURL($url, $uid, $fields, $update);
$contact = self::getByURL($url, $update, $fields, $uid);
if (!empty($contact)) {
if (!empty($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'])) {
$contact['cid'] = 0;
$contact['zid'] = $contact['id'];
@ -1318,7 +1318,7 @@ class Contact
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)) {
$contact_id = $contact["id"];

View File

@ -63,7 +63,7 @@ class AllFriends extends BaseModule
}
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);

View File

@ -971,7 +971,7 @@ class Contact extends BaseModule
if (DBA::isResult($contact)) {
DI::page()['aside'] = '';
$profiledata = Model\Contact::getByURL($contact['url'], 0, [], false);
$profiledata = Model\Contact::getByURL($contact['url'], false);
Model\Profile::load($a, '', $profiledata, true);
@ -994,7 +994,7 @@ class Contact extends BaseModule
if (DBA::isResult($contact)) {
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)) {
$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.'));
}
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.');
$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()) {
$contact = Contact::getByURLForUser($contact_url, local_user(), [], false);
} else {
$contact = Contact::getByURL($contact_url, 0, [], false);
$contact = Contact::getByURL($contact_url, false);
}
if (!count($contact)) {

View File

@ -138,7 +138,7 @@ class Poke extends BaseModule
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 = [];
foreach (DI::l10n()->getPokeVerbs() as $verb => $translations) {

View File

@ -350,7 +350,7 @@ class Acl extends BaseModule
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) {
$unknown_contacts[] = [

View File

@ -239,7 +239,7 @@ class Index extends BaseSearch
if ($isAddr) {
$contact = Contact::selectFirst(['id'], ['addr' => $search, 'uid' => 0]);
} 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)) {

View File

@ -877,7 +877,7 @@ class Post
$terms = Tag::getByURIId($item['uri-id'], [Tag::MENTION, Tag::IMPLICIT_MENTION, Tag::EXCLUSIVE_MENTION]);
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) &&
($profile['addr'] != $owner['addr']) && !strstr($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_author = Contact::getByURL($parent['author-link'], 0, ['url', 'nurl', 'alias'], false);
$parent_author = Contact::getByURL($parent['author-link'], false, ['url', 'nurl', 'alias']);
$implicit_mentions = [];
if (empty($parent_author['url'])) {
@ -1003,7 +1003,7 @@ class Processor
}
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'])) {
$implicit_mentions[] = $contact['url'];
$implicit_mentions[] = $contact['nurl'];

View File

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

View File

@ -3729,7 +3729,7 @@ class Diaspora
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'])
&& $profile['contact-type'] != Contact::TYPE_COMMUNITY
&& !strstr($body, $profile['addr'])

View File

@ -2105,7 +2105,7 @@ class OStatus
$mentioned = $newmentions;
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)) {
XML::addElement($doc, $entry, "link", "",
[