From faa30adf68a32955d9680526f722e0ca7f436a3b Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 22 Dec 2018 20:12:32 +0000 Subject: [PATCH] Handles issue 6122 - the self contact will be updated when it seems to be invalid --- src/Model/Contact.php | 11 ++++++----- src/Model/User.php | 13 +++++++++++++ 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/Model/Contact.php b/src/Model/Contact.php index af6ad46d2f..5894814ea6 100644 --- a/src/Model/Contact.php +++ b/src/Model/Contact.php @@ -460,7 +460,8 @@ class Contact extends BaseObject public static function updateSelfFromUserID($uid, $update_avatar = false) { $fields = ['id', 'name', 'nick', 'location', 'about', 'keywords', 'gender', 'avatar', - 'xmpp', 'contact-type', 'forum', 'prv', 'avatar-date', 'nurl']; + 'xmpp', 'contact-type', 'forum', 'prv', 'avatar-date', 'url', 'nurl', + 'photo', 'thumb', 'micro', 'addr', 'request', 'notify', 'poll', 'confirm', 'poco']; $self = DBA::selectFirst('contact', $fields, ['uid' => $uid, 'self' => true]); if (!DBA::isResult($self)) { return; @@ -523,15 +524,15 @@ class Contact extends BaseObject $fields['nurl'] = Strings::normaliseLink($fields['url']); $fields['addr'] = $user['nickname'] . '@' . substr(System::baseUrl(), strpos(System::baseUrl(), '://') + 3); $fields['request'] = System::baseUrl() . '/dfrn_request/' . $user['nickname']; - $fields['notify'] = System::baseUrl() . '/dfrn_notify/' . $user['nickname']; - $fields['poll'] = System::baseUrl() . '/dfrn_poll/' . $user['nickname']; + $fields['notify'] = System::baseUrl() . '/dfrn_notify/' . $user['nickname']; + $fields['poll'] = System::baseUrl() . '/dfrn_poll/'. $user['nickname']; $fields['confirm'] = System::baseUrl() . '/dfrn_confirm/' . $user['nickname']; - $fields['poco'] = System::baseUrl() . '/poco/' . $user['nickname']; + $fields['poco'] = System::baseUrl() . '/poco/' . $user['nickname']; $update = false; foreach ($fields as $field => $content) { - if (isset($self[$field]) && $self[$field] != $content) { + if ($self[$field] != $content) { $update = true; } } diff --git a/src/Model/User.php b/src/Model/User.php index 40b6c4ff15..a6a9fc9525 100644 --- a/src/Model/User.php +++ b/src/Model/User.php @@ -98,6 +98,19 @@ class User if (!DBA::isResult($r)) { return false; } + + if (empty($r['nickname'])) { + return false; + } + + // Check if the returned data is valid, otherwise fix it. See issue #6122 + $url = System::baseUrl() . '/profile/' . $r['nickname']; + $addr = $r['nickname'] . '@' . substr(System::baseUrl(), strpos(System::baseUrl(), '://') + 3); + + if (($addr != $r['addr']) || ($r['url'] != $url) || ($r['nurl'] != Strings::normaliseLink($r['url']))) { + Contact::updateSelfFromUserID($uid); + } + return $r; } -- 2.39.5