]> git.mxchange.org Git - friendica.git/commitdiff
Fix notice "undefined index: uri"
authorMichael <heluecht@pirati.ca>
Fri, 9 Jul 2021 14:52:22 +0000 (14:52 +0000)
committerMichael <heluecht@pirati.ca>
Fri, 9 Jul 2021 14:52:22 +0000 (14:52 +0000)
src/Model/APContact.php
src/Model/Contact.php

index 5c60ebae59397bcc290a67743b168ebc8b243b02..aa5dbe2f7188e8bbe898e65e62f043b8a12eacf8 100644 (file)
@@ -124,7 +124,7 @@ class APContact
                                $apcontact = DBA::selectFirst('apcontact', [], ['addr' => $url]);
                        }
 
-                       if (DBA::isResult($apcontact) && ($apcontact['updated'] > $ref_update) && !empty($apcontact['pubkey'])) {
+                       if (DBA::isResult($apcontact) && ($apcontact['updated'] > $ref_update) && !empty($apcontact['pubkey']) && !empty($apcontact['uri-id'])) {
                                return $apcontact;
                        }
 
@@ -352,7 +352,7 @@ class APContact
                if (empty($apcontact['uuid'])) {
                        $apcontact['uri-id'] = ItemURI::getIdByURI($apcontact['url']);
                } else {
-                       $apcontact['uri-id'] = ItemURI::insert(['uri' => $apcontact['uri'], 'guid' => $apcontact['uuid']]);
+                       $apcontact['uri-id'] = ItemURI::insert(['uri' => $apcontact['url'], 'guid' => $apcontact['uuid']]);
                }
 
                $apcontact['updated'] = DateTimeFormat::utcNow();
index 30158c5b4f7b627a474c268875ee16bb9f53238c..0184861c3c2d8403750bb075d5c69a03781cd43c 100644 (file)
@@ -1072,12 +1072,12 @@ class Contact
                        return 0;
                }
 
-               $contact = self::getByURL($url, false, ['id', 'network'], $uid);
+               $contact = self::getByURL($url, false, ['id', 'network', 'uri-id'], $uid);
 
                if (!empty($contact)) {
                        $contact_id = $contact["id"];
 
-                       if (empty($update)) {
+                       if (empty($update) && (!empty($contact['uri-id']) || is_bool($update))) {
                                Logger::debug('Contact found', ['url' => $url, 'uid' => $uid, 'update' => $update, 'cid' => $contact_id]);
                                return $contact_id;
                        }
@@ -2157,7 +2157,7 @@ class Contact
                if (empty($guid)) {
                        $ret['uri-id'] = ItemURI::getIdByURI($ret['url']);
                } else {
-                       $ret['uri-id'] = ItemURI::insert(['uri' => $ret['uri'], 'guid' => $guid]);
+                       $ret['uri-id'] = ItemURI::insert(['uri' => $ret['url'], 'guid' => $guid]);
                }
 
                $ret['nurl']    = Strings::normaliseLink($ret['url']);