Merge pull request #6310 from annando/issue-6122

Handles issue 6122 - the self contact will be updated when invalid
This commit is contained in:
Hypolite Petovan 2018-12-22 18:15:02 -05:00 committed by GitHub
commit 2af0542eaa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 5 deletions

View file

@ -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;
@ -531,7 +532,7 @@ class Contact extends BaseObject
$update = false;
foreach ($fields as $field => $content) {
if (isset($self[$field]) && $self[$field] != $content) {
if ($self[$field] != $content) {
$update = true;
}
}

View file

@ -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;
}