Skip to content

Commit ea6a17a

Browse files
committed
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.
1 parent 2c6b0b4 commit ea6a17a

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

CRM/Activity/BAO/Activity.php

+4
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,10 @@ public static function deleteActivityContact($activityId, $recordTypeID = NULL)
285285
* @return CRM_Activity_BAO_Activity|null|object
286286
*/
287287
public static function create(&$params) {
288+
// CRM-20958 - These fields are managed by MySQL triggers. Watch out for clients resaving stale timestamps.
289+
unset($params['created_date']);
290+
unset($params['modified_date']);
291+
288292
// check required params
289293
if (!self::dataExists($params)) {
290294
throw new CRM_Core_Exception('Not enough data to create activity object');

CRM/Case/BAO/Case.php

+4
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,10 @@ public static function add(&$params) {
8989
* @return CRM_Case_BAO_Case
9090
*/
9191
public static function &create(&$params) {
92+
// CRM-20958 - These fields are managed by MySQL triggers. Watch out for clients resaving stale timestamps.
93+
unset($params['created_date']);
94+
unset($params['modified_date']);
95+
9296
$transaction = new CRM_Core_Transaction();
9397

9498
if (!empty($params['id'])) {

0 commit comments

Comments
 (0)