]> git.mxchange.org Git - friendica.git/blobdiff - src/Model/Contact.php
Merge pull request #8832 from annando/fix-db-error
[friendica.git] / src / Model / Contact.php
index e3fc2d334d8e1d38b79e858e76daf0780626248b..b11919b52809ef74a6e1f357021453fa5f350e56 100644 (file)
@@ -926,10 +926,10 @@ class Contact
                                return;
                        }
                } elseif (!isset($contact['url'])) {
-                       Logger::log('Empty contact: ' . json_encode($contact) . ' - ' . System::callstack(20), Logger::DEBUG);
+                       Logger::info('Empty contact', ['contact' => $contact, 'callstack' => System::callstack(20)]);
                }
 
-               Logger::log('Contact '.$contact['id'].' is marked for archival', Logger::DEBUG);
+               Logger::info('Contact is marked for archival', ['id' => $contact['id']]);
 
                // Contact already archived or "self" contact? => nothing to do
                if ($contact['archive'] || $contact['self']) {
@@ -988,7 +988,7 @@ class Contact
                        return;
                }
 
-               Logger::log('Contact '.$contact['id'].' is marked as vital again', Logger::DEBUG);
+               Logger::info('Contact is marked as vital again', ['id' => $contact['id']]);
 
                if (!isset($contact['url']) && !empty($contact['id'])) {
                        $fields = ['id', 'url', 'batch'];
@@ -1489,7 +1489,7 @@ class Contact
         */
        public static function getIdForURL($url, $uid = 0, $no_update = false, $default = [], $in_loop = false)
        {
-               Logger::log("Get contact data for url " . $url . " and user " . $uid . " - " . System::callstack(), Logger::DEBUG);
+               Logger::info('Get contact data', ['url' => $url, 'user' => $uid]);
 
                $contact_id = 0;
 
@@ -1572,7 +1572,7 @@ class Contact
                        $data['gsid'] = GServer::getID($data['baseurl']);
                }
 
-               if (!$contact_id && !empty($data['alias']) && ($data['alias'] != $url) && !$in_loop) {
+               if (!$contact_id && !empty($data['alias']) && ($data['alias'] != $data['url']) && !$in_loop) {
                        $contact_id = self::getIdForURL($data["alias"], $uid, true, $default, true);
                }
 
@@ -2353,11 +2353,11 @@ class Contact
                $condition = ['uid' => $user['uid'], 'poll' => [$ret['poll'], Strings::normaliseLink($ret['poll'])], 'network' => $ret['network'], 'pending' => false];
                $contact = DBA::selectFirst('contact', ['id', 'rel'], $condition);
                if (!DBA::isResult($contact)) {
-                       $condition = ['uid' => $user['uid'], 'nurl' => Strings::normaliseLink($url), 'network' => $ret['network'], 'pending' => false];
+                       $condition = ['uid' => $user['uid'], 'nurl' => Strings::normaliseLink($ret['url']), 'network' => $ret['network'], 'pending' => false];
                        $contact = DBA::selectFirst('contact', ['id', 'rel'], $condition);
                }
 
-               $protocol = self::getProtocol($url, $ret['network']);
+               $protocol = self::getProtocol($ret['url'], $ret['network']);
 
                if (($protocol === Protocol::DFRN) && !DBA::isResult($contact)) {
                        if ($interactive) {
@@ -2394,7 +2394,7 @@ class Contact
                        if (empty($ret['url'])) {
                                $result['message'] .= DI::l10n()->t('No browser URL could be matched to this address.') . EOL;
                        }
-                       if (strpos($url, '@') !== false) {
+                       if (strpos($ret['url'], '@') !== false) {
                                $result['message'] .= DI::l10n()->t('Unable to match @-style Identity Address with a known protocol or email contact.') . EOL;
                                $result['message'] .= DI::l10n()->t('Use mailto: in front of address to force email check.') . EOL;
                        }
@@ -2418,7 +2418,7 @@ class Contact
 
                $pending = false;
                if ($protocol == Protocol::ACTIVITYPUB) {
-                       $apcontact = APContact::getByURL($url, false);
+                       $apcontact = APContact::getByURL($ret['url'], false);
                        if (isset($apcontact['manually-approve'])) {
                                $pending = (bool)$apcontact['manually-approve'];
                        }