]> git.mxchange.org Git - friendica.git/blobdiff - src/Model/Contact.php
Possibly fix a fatal error
[friendica.git] / src / Model / Contact.php
index bb876405421e0e723457e2bb302cf3e786579937..855f90431c3fd3a88919ba48986d1e3c5b7906b9 100644 (file)
@@ -207,7 +207,12 @@ class Contact
                        if (empty($cid)) {
                                return [];
                        }
-                       return self::getById($cid, $fields);
+
+                       $contact = self::getById($cid, $fields);
+                       if (empty($contact)) {
+                               return [];
+                       }
+                       return $contact;
                }
 
                // Add internal fields
@@ -238,6 +243,10 @@ class Contact
                        $contact = DBA::selectFirst('contact', $fields, $condition, $options);
                }
                
+               if (!DBA::isResult($contact)) {
+                       return [];
+               }
+
                // Update the contact in the background if needed
                if ((($contact['updated'] < DateTimeFormat::utc('now -7 days')) || empty($contact['avatar'])) &&
                        in_array($contact['network'], Protocol::FEDERATED)) {
@@ -2075,7 +2084,7 @@ class Contact
         * @throws HTTPException\InternalServerErrorException
         * @throws \ImagickException
         */
-       public static function updateFromProbe($id, $network = '', $force = false)
+       public static function updateFromProbe(int $id, string $network = '', bool $force = false)
        {
                /*
                  Warning: Never ever fetch the public key via Probe::uri and write it into the contacts.
@@ -2123,6 +2132,10 @@ class Contact
                        return false;
                }
 
+               if (ContactRelation::isDiscoverable($ret['url'])) {
+                       Worker::add(PRIORITY_LOW, 'ContactDiscovery', $ret['url']);
+               }
+
                if (isset($ret['hide']) && is_bool($ret['hide'])) {
                        $ret['unsearchable'] = $ret['hide'];
                }
@@ -2147,8 +2160,6 @@ class Contact
                        GContact::updateFromPublicContactID($id);
                }
 
-               ContactRelation::discoverByUrl($ret['url']);
-
                $update = false;
 
                // make sure to not overwrite existing values with blank entries except some technical fields