From ea6a17a90e231f4347c5bb5044f8dcf3500b7d70 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Thu, 27 Jul 2017 21:10:30 -0700 Subject: [PATCH] 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. --- CRM/Activity/BAO/Activity.php | 4 ++++ CRM/Case/BAO/Case.php | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/CRM/Activity/BAO/Activity.php b/CRM/Activity/BAO/Activity.php index 2f4386695d..ea9bd39efd 100644 --- a/CRM/Activity/BAO/Activity.php +++ b/CRM/Activity/BAO/Activity.php @@ -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'); diff --git a/CRM/Case/BAO/Case.php b/CRM/Case/BAO/Case.php index 13da2d5941..89c77bd94f 100644 --- a/CRM/Case/BAO/Case.php +++ b/CRM/Case/BAO/Case.php @@ -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'])) { -- 2.25.1