Commit ea6a17a9 authored by totten's avatar totten

CRM-20958 - Case, Activity BAOs - Watch out for saving stale timestamps

There appears to be some application logic which follows a process like this:

 1. Read the case
 2. Tweak the data
 3. Save updated case

The problem is comes if step #4 resaves a timestamp loaded in step #1, which
is fairly likely to happen if you read+save the same record.

This was specifically observed on the "Manage Case" screen when editing
activities, but the data-flow is pretty common, so make a general fix to the
BAO.
parent 2c6b0b4b
......@@ -285,6 +285,10 @@ class CRM_Activity_BAO_Activity extends CRM_Activity_DAO_Activity {
* @return CRM_Activity_BAO_Activity|null|object
*/
public static function create(&$params) {
// CRM-20958 - These fields are managed by MySQL triggers. Watch out for clients resaving stale timestamps.
unset($params['created_date']);
unset($params['modified_date']);
// check required params
if (!self::dataExists($params)) {
throw new CRM_Core_Exception('Not enough data to create activity object');
......
......@@ -89,6 +89,10 @@ class CRM_Case_BAO_Case extends CRM_Case_DAO_Case {
* @return CRM_Case_BAO_Case
*/
public static function &create(&$params) {
// CRM-20958 - These fields are managed by MySQL triggers. Watch out for clients resaving stale timestamps.
unset($params['created_date']);
unset($params['modified_date']);
$transaction = new CRM_Core_Transaction();
if (!empty($params['id'])) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment