X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FCore%2FTransaction.php;h=04be629fb36f7ce17b522544cc93b79f8f1cf7fd;hb=10781258d3d7c96bdae5a28ce0da6bed3c1acc33;hp=b00ce04135fae231224732422ea974e1aacef063;hpb=c735fb7e38514eb6d7732ffb11ac21ac33e570b9;p=civicrm-core.git diff --git a/CRM/Core/Transaction.php b/CRM/Core/Transaction.php index b00ce04135..04be629fb3 100644 --- a/CRM/Core/Transaction.php +++ b/CRM/Core/Transaction.php @@ -236,4 +236,24 @@ class CRM_Core_Transaction { $frame->addCallback($phase, $callback, $params, $id); } + /** + * Whenever hook_civicrm_post fires, schedule an equivalent + * call to hook_civicrm_postCommit. + * + * @param \Civi\Core\Event\PostEvent $e + * @see CRM_Utils_Hook::post + */ + public static function addPostCommit($e) { + // Do we want to dedupe post-commit hooks for the same txn? Setting an ID + // would allow this. + // $id = $e->entity . chr(0) . $e->action . chr(0) . $e->id; + $frame = \Civi\Core\Transaction\Manager::singleton()->getBaseFrame(); + if ($frame) { + $frame->addCallback(self::PHASE_POST_COMMIT, ['CRM_Utils_Hook', 'postCommit'], [$e->action, $e->entity, $e->id, $e->object]); + } + else { + \CRM_Utils_Hook::postCommit($e->action, $e->entity, $e->id, $e->object); + } + } + }