X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=Civi%2FCCase%2FEvents.php;h=472ac9f6471312a7616dcd6dcb7b2fb3f1e85463;hb=785b0cfda8edb302604577e5992ad8168ddca3d8;hp=9c5c10c588758508d51b306f12193c588adc6f3b;hpb=d32488affd66dd2e6494175442a7f17ae98c537e;p=civicrm-core.git diff --git a/Civi/CCase/Events.php b/Civi/CCase/Events.php index 9c5c10c588..472ac9f647 100644 --- a/Civi/CCase/Events.php +++ b/Civi/CCase/Events.php @@ -44,7 +44,7 @@ class Events { $caseId = NULL; switch ($event->entity) { case 'Activity': - if ($event->object->case_id) { + if (!empty($event->object->case_id)) { $caseId = $event->object->case_id; } break; @@ -55,11 +55,26 @@ class Events { throw new \CRM_Core_Exception("CRM_Case_Listener does not support entity {$event->entity}"); } - if ($caseId && !isset(self::$isActive[$caseId])) { + if ($caseId) { + if (!isset(self::$isActive[$caseId])) { + \CRM_Core_Transaction::addCallback( + \CRM_Core_Transaction::PHASE_POST_COMMIT, + array(__CLASS__, 'fireCaseChangeForRealz'), + array($caseId), + "Civi_CCase_Events::fire::{$caseId}" + ); + } + } + } + + public static function fireCaseChangeForRealz($caseId) { + if (!isset(self::$isActive[$caseId])) { + $tx = new \CRM_Core_Transaction(); self::$isActive[$caseId] = 1; $analyzer = new \Civi\CCase\Analyzer($caseId); \CRM_Utils_Hook::caseChange($analyzer); unset(self::$isActive[$caseId]); + unset($tx); } }