From 48d849b189bca0d7b2675b180b72e9a394cd60e4 Mon Sep 17 00:00:00 2001 From: deepak-srivastava Date: Thu, 2 Oct 2014 15:41:47 +0100 Subject: [PATCH] consider dao->delete result for triggerDelete() --- CRM/Core/BAO/RecurringEntity.php | 5 +++-- CRM/Core/DAO.php | 2 +- Civi/Core/DAO/Event/PostDelete.php | 8 +++++++- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/CRM/Core/BAO/RecurringEntity.php b/CRM/Core/BAO/RecurringEntity.php index 0e92e02791..c48be354ce 100644 --- a/CRM/Core/BAO/RecurringEntity.php +++ b/CRM/Core/BAO/RecurringEntity.php @@ -653,6 +653,8 @@ class CRM_Core_BAO_RecurringEntity extends CRM_Core_DAO_RecurringEntity { * @return void */ static public function triggerDelete($event){ + $obj =& $event->object; + // if DB version is earlier than 4.6 skip any processing static $currentVer = NULL; if (!$currentVer) { @@ -663,8 +665,7 @@ class CRM_Core_BAO_RecurringEntity extends CRM_Core_DAO_RecurringEntity { } static $processedEntities = array(); - $obj =& $event->object; - if (empty($obj->id) || empty($obj->__table)) { + if (empty($obj->id) || empty($obj->__table) || !$event->result) { return FALSE; } $key = "{$obj->__table}_{$obj->id}"; diff --git a/CRM/Core/DAO.php b/CRM/Core/DAO.php index bfdf3964c9..7f990f5a7b 100644 --- a/CRM/Core/DAO.php +++ b/CRM/Core/DAO.php @@ -470,7 +470,7 @@ class CRM_Core_DAO extends DB_DataObject { function delete($useWhere = FALSE) { $result = parent::delete($useWhere); - $event = new \Civi\Core\DAO\Event\PostDelete($this); + $event = new \Civi\Core\DAO\Event\PostDelete($this, $result); \Civi\Core\Container::singleton()->get('dispatcher')->dispatch("DAO::post-delete", $event); return $result; diff --git a/Civi/Core/DAO/Event/PostDelete.php b/Civi/Core/DAO/Event/PostDelete.php index 1fd5485cb8..c50895ecf8 100644 --- a/Civi/Core/DAO/Event/PostDelete.php +++ b/Civi/Core/DAO/Event/PostDelete.php @@ -38,7 +38,13 @@ class PostDelete extends \Symfony\Component\EventDispatcher\Event { */ public $object; - function __construct($object) { + /** + * @var DAO delete result + */ + public $result; + + function __construct($object, $result) { $this->object = $object; + $this->result = $result; } } -- 2.25.1