Skip to content

Add pre/post eventID tracking to map original/current values for 'Old value/New value' comparisons

mattwire requested to merge mattwire/civirules:preposteventid into master

Requires https://github.com/civicrm/civicrm-core/pull/19209

There is no way to link a preInsert/Update event with a postInsert/Update event for the same entity/change. Normally this doesn't matter but for a "busy" site or where there are multiple things happening based on a change to an entity this is problematic.

This came up specifically on a site with:

CiviRules configured with a number of Activity "Old value is X / New value is Y" where you need to store the original data (retrieve it from the DB during the pre) and compare with the new data (compare during the post). Another extension using Activity post hook to calculate some "scores" based on submitted custom values and save back to the activity in another custom field. This resulted in inconsistent behaviour which we tracked down to timing issues. Sometimes the pre-hook fired for both 1 and 2 BEFORE the post hook had fired for the relevant change. Resulting in the "original data" being overwritten by the second pre-hook and not matching the change that was being checked in the post hook.

Edited by mattwire

Merge request reports