Merge pull request #8737 from annando/issue-8735

Issue 8735: Ensure the correct data type for "hide"
This commit is contained in:
Hypolite Petovan 2020-06-06 08:35:57 -04:00 committed by GitHub
commit b3c07fc726
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 7 deletions

View file

@ -627,11 +627,6 @@ class GContact
$contact['network'] = Protocol::OSTATUS; $contact['network'] = Protocol::OSTATUS;
} }
// All new contacts are hidden by default
if (!isset($contact['hide'])) {
$contact['hide'] = true;
}
// Remove unwanted parts from the contact url (e.g. '?zrl=...') // Remove unwanted parts from the contact url (e.g. '?zrl=...')
if (in_array($contact['network'], Protocol::FEDERATED)) { if (in_array($contact['network'], Protocol::FEDERATED)) {
$contact['url'] = self::cleanContactUrl($contact['url']); $contact['url'] = self::cleanContactUrl($contact['url']);
@ -646,6 +641,7 @@ class GContact
$contact['location'] = $contact['location'] ?? ''; $contact['location'] = $contact['location'] ?? '';
$contact['about'] = $contact['about'] ?? ''; $contact['about'] = $contact['about'] ?? '';
$contact['generation'] = $contact['generation'] ?? 0; $contact['generation'] = $contact['generation'] ?? 0;
$contact['hide'] = $contact['hide'] ?? true;
$fields = ['name' => $contact['name'], 'nick' => $contact['nick'] ?? '', 'addr' => $contact['addr'] ?? '', 'network' => $contact['network'], $fields = ['name' => $contact['name'], 'nick' => $contact['nick'] ?? '', 'addr' => $contact['addr'] ?? '', 'network' => $contact['network'],
'url' => $contact['url'], 'nurl' => Strings::normaliseLink($contact['url']), 'photo' => $contact['photo'], 'url' => $contact['url'], 'nurl' => Strings::normaliseLink($contact['url']), 'photo' => $contact['photo'],

View file

@ -92,7 +92,11 @@ class Probe
$newdata = []; $newdata = [];
foreach ($fields as $field) { foreach ($fields as $field) {
if (isset($data[$field])) { if (isset($data[$field])) {
$newdata[$field] = $data[$field]; if (in_array($field, ["gsid", "hide", "account-type"])) {
$newdata[$field] = (int)$data[$field];
} else {
$newdata[$field] = $data[$field];
}
} elseif ($field != "gsid") { } elseif ($field != "gsid") {
$newdata[$field] = ""; $newdata[$field] = "";
} else { } else {
@ -398,7 +402,7 @@ class Probe
// When the previous detection process had got a time out // When the previous detection process had got a time out
// we could falsely detect a Friendica profile as AP profile. // we could falsely detect a Friendica profile as AP profile.
if (!self::$istimeout) { if (!self::$istimeout) {
$ap_profile = ActivityPub::probeProfile($uri); $ap_profile = ActivityPub::probeProfile($uri, !$cache);
if (empty($data) || (!empty($ap_profile) && empty($network) && (($data['network'] ?? '') != Protocol::DFRN))) { if (empty($data) || (!empty($ap_profile) && empty($network) && (($data['network'] ?? '') != Protocol::DFRN))) {
$data = $ap_profile; $data = $ap_profile;