Skip to content

Commit

Permalink
CRM-20958 - Case, Activity BAOs - Watch out for saving stale timestamps
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
totten committed Sep 6, 2017
1 parent 2c6b0b4 commit ea6a17a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CRM/Activity/BAO/Activity.php
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,10 @@ public static function deleteActivityContact($activityId, $recordTypeID = NULL)
* @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');
Expand Down
4 changes: 4 additions & 0 deletions CRM/Case/BAO/Case.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ public static function add(&$params) {
* @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'])) {
Expand Down

0 comments on commit ea6a17a

Please sign in to comment.