From 9f35e05dba63143cd8cde24d8453812152e39de2 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Tue, 15 Sep 2015 21:41:23 -0700 Subject: [PATCH] CRM-14707 - CRM_Core_BAO_Cache::setItem - Don't fire hooks --- CRM/Core/BAO/Cache.php | 2 +- CRM/Core/DAO.php | 18 ++++++++++++------ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/CRM/Core/BAO/Cache.php b/CRM/Core/BAO/Cache.php index d6eb3d39ef..cb504ed9dd 100644 --- a/CRM/Core/BAO/Cache.php +++ b/CRM/Core/BAO/Cache.php @@ -161,7 +161,7 @@ class CRM_Core_BAO_Cache extends CRM_Core_DAO_Cache { $dao->find(TRUE); $dao->data = serialize($data); $dao->created_date = date('YmdHis'); - $dao->save(); + $dao->save(FALSE); $lock->release(); diff --git a/CRM/Core/DAO.php b/CRM/Core/DAO.php index e139a3d9fa..baa3033c9d 100644 --- a/CRM/Core/DAO.php +++ b/CRM/Core/DAO.php @@ -433,22 +433,28 @@ class CRM_Core_DAO extends DB_DataObject { /** * @return $this */ - public function save() { + public function save($hook = TRUE) { if (!empty($this->id)) { $this->update(); - $event = new \Civi\Core\DAO\Event\PostUpdate($this); - \Civi::service('dispatcher')->dispatch("DAO::post-update", $event); + if ($hook) { + $event = new \Civi\Core\DAO\Event\PostUpdate($this); + \Civi::service('dispatcher')->dispatch("DAO::post-update", $event); + } } else { $this->insert(); - $event = new \Civi\Core\DAO\Event\PostUpdate($this); - \Civi::service('dispatcher')->dispatch("DAO::post-insert", $event); + if ($hook) { + $event = new \Civi\Core\DAO\Event\PostUpdate($this); + \Civi::service('dispatcher')->dispatch("DAO::post-insert", $event); + } } $this->free(); - CRM_Utils_Hook::postSave($this); + if ($hook) { + CRM_Utils_Hook::postSave($this); + } return $this; } -- 2.25.1