Skip to content
Snippets Groups Projects
Commit e1639c79 authored by mattwire's avatar mattwire
Browse files

Automatically handle deprecated trxn_id on civicrm_contribution_recur

parent 4ead2be0
No related branches found
Tags 0.9.8
1 merge request!23Release 1.1
...@@ -28,6 +28,9 @@ function mjwshared_civicrm_config(&$config) { ...@@ -28,6 +28,9 @@ function mjwshared_civicrm_config(&$config) {
Civi::dispatcher()->addListener('hook_civicrm_buildAsset', 'mjwshared_symfony_civicrm_buildAsset', -990); Civi::dispatcher()->addListener('hook_civicrm_buildAsset', 'mjwshared_symfony_civicrm_buildAsset', -990);
// This should run before (almost) anything else as we're loading shared libraries // This should run before (almost) anything else as we're loading shared libraries
Civi::dispatcher()->addListener('hook_civicrm_coreResourceList', 'mjwshared_symfony_civicrm_coreResourceList', 1000); Civi::dispatcher()->addListener('hook_civicrm_coreResourceList', 'mjwshared_symfony_civicrm_coreResourceList', 1000);
\Civi::dispatcher()->addListener('civi.dao.preUpdate', 'mjwshared_symfony_preUpdateInsert');
\Civi::dispatcher()->addListener('civi.dao.preInsert', 'mjwshared_symfony_preUpdateInsert');
} }
/** /**
...@@ -264,3 +267,24 @@ function mjwshared_civicrm_buildForm($formName, &$form) { ...@@ -264,3 +267,24 @@ function mjwshared_civicrm_buildForm($formName, &$form) {
\Civi::resources()->addVars('payment', $jsVars); \Civi::resources()->addVars('payment', $jsVars);
} }
/**
* @param \Civi\Core\DAO\Event\PreUpdate $event
*/
function mjwshared_symfony_preUpdateInsert(\Civi\Core\DAO\Event\PreUpdate $event) {
if ($event->object instanceof CRM_Contribute_BAO_ContributionRecur) {
// Handle deprecated civicrm_contribution_recur.trxn_id and set it to match processor_id if empty
if (!empty($event->object->processor_id) && empty($event->object->trxn_id)) {
// We set trxn_id to match processor_id as it is still used in some places
$event->object->trxn_id = $event->object->processor_id;
}
elseif (!empty($event->object->trxn_id) && empty($event->object->processor_id)) {
// warn old set
CRM_Core_Error::deprecatedFunctionWarning('civicrm_contribution_recur.processor_id', 'civicrm_contribution_recur.trxn_id');
}
if (!empty($event->object->trxn_id) && !empty($event->object->processor_id) && ($event->object->trxn_id !== $event->object->processor_id)) {
// Warn set to different values
CRM_Core_Error::deprecatedWarning("Recur ID: {$event->object->id}; civicrm_contribution_recur processor_id is different to trxn_id. trxn_id is deprecated and should be empty or match processor_id");
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment