X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FCore%2FDAO.php;h=0b91105864f203ff040b633288fddcedfaec9353;hb=0b591f3d4c8c28a777f80ffe71ee83abba8457cd;hp=e6813869de29c2b848400e29c30fea6380efa531;hpb=e546963c864bef54f6d01a6346c2c83b77b9e05c;p=civicrm-core.git diff --git a/CRM/Core/DAO.php b/CRM/Core/DAO.php index e6813869de..0b91105864 100644 --- a/CRM/Core/DAO.php +++ b/CRM/Core/DAO.php @@ -543,20 +543,30 @@ class CRM_Core_DAO extends DB_DataObject { */ public function save($hook = TRUE) { if (!empty($this->id)) { - $this->update(); + if ($hook) { + $preEvent = new \Civi\Core\DAO\Event\PreUpdate($this); + \Civi::dispatcher()->dispatch("civi.dao.preUpdate", $preEvent); + } + + $result = $this->update(); if ($hook) { - $event = new \Civi\Core\DAO\Event\PostUpdate($this); - \Civi::service('dispatcher')->dispatch("civi.dao.postUpdate", $event); + $event = new \Civi\Core\DAO\Event\PostUpdate($this, $result); + \Civi::dispatcher()->dispatch("civi.dao.postUpdate", $event); } $this->clearDbColumnValueCache(); } else { - $this->insert(); + if ($hook) { + $preEvent = new \Civi\Core\DAO\Event\PreUpdate($this); + \Civi::dispatcher()->dispatch("civi.dao.preInsert", $preEvent); + } + + $result = $this->insert(); if ($hook) { - $event = new \Civi\Core\DAO\Event\PostUpdate($this); - \Civi::service('dispatcher')->dispatch("civi.dao.postInsert", $event); + $event = new \Civi\Core\DAO\Event\PostUpdate($this, $result); + \Civi::dispatcher()->dispatch("civi.dao.postInsert", $event); } } $this->free(); @@ -595,12 +605,12 @@ class CRM_Core_DAO extends DB_DataObject { */ public function delete($useWhere = FALSE) { $preEvent = new \Civi\Core\DAO\Event\PreDelete($this); - \Civi::service('dispatcher')->dispatch("civi.dao.preDelete", $preEvent); + \Civi::dispatcher()->dispatch("civi.dao.preDelete", $preEvent); $result = parent::delete($useWhere); $event = new \Civi\Core\DAO\Event\PostDelete($this, $result); - \Civi::service('dispatcher')->dispatch("civi.dao.postDelete", $event); + \Civi::dispatcher()->dispatch("civi.dao.postDelete", $event); $this->free(); $this->clearDbColumnValueCache(); @@ -2471,6 +2481,7 @@ SELECT contact_id $fields = civicrm_api3('CustomField', 'get', [ 'return' => ['column_name', 'custom_group_id.table_name'], 'data_type' => 'ContactReference', + 'options' => ['limit' => 0], ])['values']; foreach ($fields as $field) { $cidRefs[$field['custom_group_id.table_name']][] = $field['column_name'];