Skip to content

Instantly share code, notes, and snippets.

@mlutfy
Last active September 9, 2017 21:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mlutfy/6e08a51c6878cc05077e616213ec165e to your computer and use it in GitHub Desktop.
Save mlutfy/6e08a51c6878cc05077e616213ec165e to your computer and use it in GitHub Desktop.
CiviCRM logging timestamp weird bug (CRM/Logging/Schema.php)
/**
* Fix timestamp.
*
* Log_civicrm_contact.modified_date for example would always be copied from civicrm_contact.modified_date,
* so there's no need for a default timestamp and therefore we remove such default timestamps
* also eliminate the NOT NULL constraint, since we always copy and schema can change down the road)
*
* @param string $query
*
* @return mixed
*/
public function fixTimeStampAndNotNullSQL($query) {
$query = str_ireplace("TIMESTAMP NOT NULL", "TIMESTAMP NULL", $query);
$query = str_ireplace("DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP", '', $query);
$query = str_ireplace("DEFAULT CURRENT_TIMESTAMP", '', $query);
$query = str_ireplace("NOT NULL", '', $query);
$query = str_ireplace('()', ' ', $query); // [ML]
return $query;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment