From 2062669201836814857d08726ee711636a956ee7 Mon Sep 17 00:00:00 2001 From: eileen Date: Tue, 11 Apr 2017 18:33:04 +1200 Subject: [PATCH 1/2] CRM-20178 do not skip timestamps --- DB/DataObject.php | 5 ----- 1 file changed, 5 deletions(-) diff --git a/DB/DataObject.php b/DB/DataObject.php index 9636b9a5f..10e9fcf35 100644 --- a/DB/DataObject.php +++ b/DB/DataObject.php @@ -968,11 +968,6 @@ function insert() if (!isset($this->$k)) { continue; } - // dont insert data into mysql timestamps - // use query() if you really want to do this!!!! - if ($v & DB_DATAOBJECT_MYSQLTIMESTAMP) { - continue; - } if ($leftq) { $leftq .= ', '; From d26941f3bffca48ded954e64808be37fc0cc29d7 Mon Sep 17 00:00:00 2001 From: eileen Date: Tue, 11 Apr 2017 18:40:10 +1200 Subject: [PATCH 2/2] CRM-20414 (from CRM-14986) make DAO cope with DB dates (& datepicker dates) on update --- DB/DataObject.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/DB/DataObject.php b/DB/DataObject.php index 10e9fcf35..0d74ece76 100644 --- a/DB/DataObject.php +++ b/DB/DataObject.php @@ -994,6 +994,19 @@ function insert() $rightq .= " NULL "; continue; } + if (($v & DB_DATAOBJECT_DATE) || ($v & DB_DATAOBJECT_TIME) || $v & DB_DATAOBJECT_MYSQLTIMESTAMP) { + if (strpos($this->$k, '-') !== FALSE) { + /* + * per CRM-14986 we have been having ongoing problems with the format returned from $dao->find(TRUE) NOT + * being acceptable for an immediate save. This has resulted in the codebase being smattered with + * instances of CRM_Utils_Date::isoToMysql for date fields retrieved in this way + * which seems both risky (have to remember to do it for every field) & cludgey. + * doing it here should be safe as only fields with a '-' in them will be affected - if they are + * already formatted or empty then this line will not be hit + */ + $this->$k = CRM_Utils_Date::isoToMysql($this->$k); + } + } // DATE is empty... on a col. that can be null.. // note: this may be usefull for time as well.. if (!$this->$k &&