1
1
Fork 0

Merge pull request #4679 from annando/issue-4673

Issue 4673: Avoid "Incorrect date value: '0000-00-00' for column 'bd'"
This commit is contained in:
Hypolite Petovan 2018-03-24 18:59:04 -04:00 committed by GitHub
commit 7f3db49742
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -873,7 +873,8 @@ class GContact
// Now update the contact entry with the user id "0" as well. // Now update the contact entry with the user id "0" as well.
// This is used for the shadow copies of public items. // 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]); $public_contact = dba::selectFirst('contact', ['id'], ['nurl' => normalise_link($contact["url"]), 'uid' => 0]);
if (DBM::is_result($public_contact)) { if (DBM::is_result($public_contact)) {
logger("Update public contact ".$public_contact["id"], LOGGER_DEBUG); logger("Update public contact ".$public_contact["id"], LOGGER_DEBUG);
@ -894,6 +895,12 @@ class GContact
'contact-type' => $contact['contact-type'], 'url' => $contact['url'], 'contact-type' => $contact['contact-type'], 'url' => $contact['url'],
'location' => $contact['location'], 'about' => $contact['about']]; '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); dba::update('contact', $fields, ['id' => $public_contact["id"]], $old_contact);
} }
} }