From 2c57d73be5eb825b1e8513953acbf76963840c63 Mon Sep 17 00:00:00 2001 From: Jaap Jansma Date: Wed, 13 Jun 2018 11:19:11 +0200 Subject: [PATCH] Fix for #180: passing the entity ID to the custom hook when deleting a custom value record. --- CRM/Core/BAO/CustomValue.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/CRM/Core/BAO/CustomValue.php b/CRM/Core/BAO/CustomValue.php index 516eb9fe6d..ce72448de2 100644 --- a/CRM/Core/BAO/CustomValue.php +++ b/CRM/Core/BAO/CustomValue.php @@ -207,13 +207,18 @@ class CRM_Core_BAO_CustomValue extends CRM_Core_DAO { // first we need to find custom value table, from custom group ID $tableName = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomGroup', $customGroupID, 'table_name'); + // Retrieve the $entityId so we can pass that to the hook. + $entityID = CRM_Core_DAO::singleValueQuery("SELECT entity_id FROM {$tableName} WHERE id = %1", array( + 1 => array($customValueID, 'Integer'), + )); + // delete custom value from corresponding custom value table $sql = "DELETE FROM {$tableName} WHERE id = {$customValueID}"; CRM_Core_DAO::executeQuery($sql); CRM_Utils_Hook::custom('delete', $customGroupID, - NULL, + $entityID, $customValueID ); } -- 2.25.1