Fix fallback on unknown contact

This commit is contained in:
Michael 2020-07-16 04:18:33 +00:00
parent caf548e1a7
commit b8682190de
6 changed files with 9 additions and 9 deletions

View File

@ -164,7 +164,7 @@ function display_fetchauthor($a, $item)
$profiledata["about"] = ""; $profiledata["about"] = "";
} }
$profiledata = array_merge($profiledata, Contact::getByURLForUser($profiledata["url"], local_user())); $profiledata = Contact::getByURLForUser($profiledata["url"], local_user()) ?: $profiledata;
if (!empty($profiledata["photo"])) { if (!empty($profiledata["photo"])) {
$profiledata["photo"] = DI::baseUrl()->remove($profiledata["photo"]); $profiledata["photo"] = DI::baseUrl()->remove($profiledata["photo"]);

View File

@ -104,7 +104,7 @@ function suggest_content(App $a)
'hide' => [DI::l10n()->t('Ignore/Hide'), $ignlnk] 'hide' => [DI::l10n()->t('Ignore/Hide'), $ignlnk]
]; ];
$contact_details = array_merge($rr, Contact::getByURLForUser($rr["url"], local_user())); $contact_details = Contact::getByURLForUser($rr["url"], local_user()) ?: $rr;
$entry = [ $entry = [
'url' => Contact::magicLink($rr['url']), 'url' => Contact::magicLink($rr['url']),

View File

@ -202,7 +202,7 @@ class Search
return $resultList; return $resultList;
} }
$data = DBA::select('gcontact', ['nurl'], [ $data = DBA::select('gcontact', ['nurl', 'name', 'addr', 'url', 'photo', 'network', 'keywords'], [
'NOT `hide` 'NOT `hide`
AND `network` IN (?, ?, ?, ?) AND `network` IN (?, ?, ?, ?)
AND ((`last_contact` >= `last_failure`) OR (`updated` >= `last_failure`)) AND ((`last_contact` >= `last_failure`) OR (`updated` >= `last_failure`))
@ -232,7 +232,7 @@ class Search
continue; continue;
} }
$contact = Contact::getByURLForUser($row["nurl"], local_user()); $contact = Contact::getByURLForUser($row["nurl"], local_user()) ?: $row;
if ($contact["name"] == "") { if ($contact["name"] == "") {
$contact["name"] = end(explode("/", $urlParts["path"])); $contact["name"] = end(explode("/", $urlParts["path"]));
@ -245,8 +245,8 @@ class Search
$contact["url"], $contact["url"],
$contact["photo"], $contact["photo"],
$contact["network"], $contact["network"],
$contact["cid"], $contact["cid"] ?? 0,
$contact["zid"], $contact["zid"] ?? 0,
$contact["keywords"] $contact["keywords"]
); );

View File

@ -79,7 +79,7 @@ class AllFriends extends BaseModule
$entries = []; $entries = [];
foreach ($friends as $friend) { foreach ($friends as $friend) {
//get further details of the contact //get further details of the contact
$contactDetails = array_merge($friend, Model\Contact::getByURLForUser($friend['url'], $uid)); $contactDetails = Model\Contact::getByURLForUser($friend['url'], $uid) ?: $friend;
$connlnk = ''; $connlnk = '';
// $friend[cid] is only available for common contacts. So if the contact is a common one, use contact_photo_menu to generate the photoMenu // $friend[cid] is only available for common contacts. So if the contact is a common one, use contact_photo_menu to generate the photoMenu

View File

@ -103,7 +103,7 @@ class Contacts extends BaseProfile
continue; continue;
} }
$contact_details = array_merge($contact, Contact::getByURLForUser($contact['url'], $a->profile['uid'])); $contact_details = Contact::getByURLForUser($contact['url'], $a->profile['uid']) ?: $contact;
$contacts[] = [ $contacts[] = [
'id' => $contact['id'], 'id' => $contact['id'],

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, null, ['id'])); $contact = Contact::getByURL($search, null, ['id']) ?: ['id' => 0];
} }
if (DBA::isResult($contact)) { if (DBA::isResult($contact)) {