Skip to content

Commit

Permalink
Merge pull request #178 from eileenmcnaughton/db
Browse files Browse the repository at this point in the history
CRM-20178 & CRM-20414 apply db level fixes to update (only applied to insert)
  • Loading branch information
monishdeb authored Apr 11, 2017
2 parents a9a0fc5 + d26941f commit 6123d32
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions DB/DataObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 .= ', ';
Expand All @@ -999,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 &&
Expand Down

0 comments on commit 6123d32

Please sign in to comment.