From: Michael Date: Sat, 24 Mar 2018 22:27:04 +0000 (+0000) Subject: Issue 4673: Avoid "Incorrect date value: '0000-00-00' for column 'bd'" X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=e8e6436f0893e3dbfdff839298a60296d0da7bcb;p=friendica.git Issue 4673: Avoid "Incorrect date value: '0000-00-00' for column 'bd'" --- diff --git a/src/Model/GContact.php b/src/Model/GContact.php index d098e8fa4a..8f16c07fc1 100644 --- a/src/Model/GContact.php +++ b/src/Model/GContact.php @@ -873,7 +873,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); @@ -894,6 +895,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); } }