Merge pull request #3182 from annando/bugfix-sql-date
Bugfix for badly formatted date time string
This commit is contained in:
commit
0d1c8139ae
2 changed files with 30 additions and 1 deletions
|
@ -86,5 +86,29 @@ class dbm {
|
|||
public static function esc_array(&$arr, $add_quotation = false) {
|
||||
array_walk($arr, 'self::esc_array_callback', $add_quotation);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks Converts any date string into a SQL compatible date string
|
||||
*
|
||||
* @param string $date a date string in any format
|
||||
* @return string SQL style date string
|
||||
*/
|
||||
public static function date($date = 'now') {
|
||||
$timestamp = strtotime($date);
|
||||
|
||||
// Workaround for 3.5.1
|
||||
if ($timestamp < -62135596800) {
|
||||
return '0000-00-00 00:00:00';
|
||||
}
|
||||
|
||||
// The above will be removed in 3.5.2
|
||||
// The following will then be enabled
|
||||
// Don't allow lower date strings as '0001-01-01 00:00:00'
|
||||
//if ($timestamp < -62135596800) {
|
||||
// $timestamp = -62135596800;
|
||||
//}
|
||||
|
||||
return date('Y-m-d H:i:s', $timestamp);
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
|
@ -622,7 +622,7 @@ function poco_last_updated($profile, $force = false) {
|
|||
$last_updated = "0000-00-00 00:00:00";
|
||||
|
||||
q("UPDATE `gcontact` SET `updated` = '%s', `last_contact` = '%s' WHERE `nurl` = '%s'",
|
||||
dbesc($last_updated), dbesc(datetime_convert()), dbesc(normalise_link($profile)));
|
||||
dbesc(dbm::date($last_updated)), dbesc(dbm::date()), dbesc(normalise_link($profile)));
|
||||
|
||||
if (($gcontacts[0]["generation"] == 0))
|
||||
q("UPDATE `gcontact` SET `generation` = 9 WHERE `nurl` = '%s'",
|
||||
|
@ -1592,6 +1592,11 @@ function get_gcontact_id($contact) {
|
|||
*/
|
||||
function update_gcontact($contact) {
|
||||
|
||||
// Check for invalid "contact-type" value
|
||||
if (isset($contact['contact-type']) AND (intval($contact['contact-type']) < 0)) {
|
||||
$contact['contact-type'] = 0;
|
||||
}
|
||||
|
||||
/// @todo update contact table as well
|
||||
|
||||
$gcontact_id = get_gcontact_id($contact);
|
||||
|
|
Loading…
Reference in a new issue