- // CRM-7353: if nothing altered civicrm_contact, touch it; this will
- // make sure there’s an entry in log_civicrm_contact for this revert
- if (empty($diffs['civicrm_contact'])) {
- $query = "
- SELECT id FROM `{$this->db}`.log_civicrm_contact
- WHERE log_conn_id = %1 AND log_date BETWEEN DATE_SUB(%2, INTERVAL 10 SECOND) AND DATE_ADD(%2, INTERVAL 10 SECOND)
- ORDER BY log_date DESC LIMIT 1
- ";
- $params = array(
- 1 => array($this->log_conn_id, 'String'),
- 2 => array($this->log_date, 'String'),
- );
- $cid = CRM_Core_DAO::singleValueQuery($query, $params);
- if (!$cid) {
- return;
- }
-
- $dao = new CRM_Contact_DAO_Contact();
- $dao->id = $cid;
- if ($dao->find(TRUE)) {
- // CRM-8102: MySQL can’t parse its own dates
- $dao->birth_date = CRM_Utils_Date::isoToMysql($dao->birth_date);
- $dao->deceased_date = CRM_Utils_Date::isoToMysql($dao->deceased_date);
- $dao->save();
- }
- }