]> git.mxchange.org Git - friendica.git/blobdiff - src/Model/GContact.php
Merge pull request #5036 from Alkarex/fix-constants
[friendica.git] / src / Model / GContact.php
index 66996c4479b58556c8319c8a85aed4d28f31ea82..c413bef4fa9ebde5d1a5cf95aab08c663a6f1dd2 100644 (file)
@@ -20,7 +20,6 @@ use dba;
 use Exception;
 
 require_once 'include/dba.php';
-require_once 'include/html2bbcode.php';
 
 /**
  * @brief This class handles GlobalContact related functions
@@ -240,10 +239,8 @@ class GContact
 
                        if ($alternate && ($gcontact['network'] == NETWORK_OSTATUS)) {
                                // Delete the old entry - if it exists
-                               $r = q("SELECT `id` FROM `gcontact` WHERE `nurl` = '%s'", dbesc(normalise_link($orig_profile)));
-                               if (DBM::is_result($r)) {
-                                       q("DELETE FROM `gcontact` WHERE `nurl` = '%s'", dbesc(normalise_link($orig_profile)));
-                                       q("DELETE FROM `glink` WHERE `gcid` = %d", intval($r[0]["id"]));
+                               if (dba::exists('gcontact', ['nurl' => normalise_link($orig_profile)])) {
+                                       dba::delete('gcontact', ['nurl' => normalise_link($orig_profile)]);
                                }
                        }
                }
@@ -874,7 +871,8 @@ class GContact
 
                        // Now update the contact entry with the user id "0" as well.
                        // This is used for the shadow copies of public items.
-
+                       /// @todo Check if we really should do this.
+                       // The quality of the gcontact table is mostly lower than the public contact
                        $public_contact = dba::selectFirst('contact', ['id'], ['nurl' => normalise_link($contact["url"]), 'uid' => 0]);
                        if (DBM::is_result($public_contact)) {
                                logger("Update public contact ".$public_contact["id"], LOGGER_DEBUG);
@@ -895,6 +893,12 @@ class GContact
                                                'contact-type' => $contact['contact-type'], 'url' => $contact['url'],
                                                'location' => $contact['location'], 'about' => $contact['about']];
 
+                               // Don't update the birthday field if not set or invalid
+                               if (empty($contact['birthday']) || ($contact['birthday'] < '0001-01-01')) {
+                                       unset($fields['bd']);
+                               }
+
+
                                dba::update('contact', $fields, ['id' => $public_contact["id"]], $old_contact);
                        }
                }