diff --git a/CRM/Core/BAO/CustomValue.php b/CRM/Core/BAO/CustomValue.php index 555077b0428c190e93c682eec1395a860316373b..ebf1f75aa09a7897e8e9fedfef33c479966a3a47 100644 --- a/CRM/Core/BAO/CustomValue.php +++ b/CRM/Core/BAO/CustomValue.php @@ -194,7 +194,7 @@ class CRM_Core_BAO_CustomValue extends CRM_Core_DAO { $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", [ + $entityID = (int) CRM_Core_DAO::singleValueQuery("SELECT entity_id FROM {$tableName} WHERE id = %1", [ 1 => [$customValueID, 'Integer'], ]); @@ -203,7 +203,7 @@ class CRM_Core_BAO_CustomValue extends CRM_Core_DAO { CRM_Core_DAO::executeQuery($sql); CRM_Utils_Hook::custom('delete', - $customGroupID, + (int) $customGroupID, $entityID, $customValueID ); diff --git a/CRM/Core/BAO/CustomValueTable.php b/CRM/Core/BAO/CustomValueTable.php index 3b6807beae8fb8d748c0d4c06c7d8c8db2c76bc0..714c9c7b43a5c3c9a04b166e4ab2202769bc7ec9 100644 --- a/CRM/Core/BAO/CustomValueTable.php +++ b/CRM/Core/BAO/CustomValueTable.php @@ -45,8 +45,7 @@ class CRM_Core_BAO_CustomValueTable { $count = 1; $firstField = reset($fields); - $entityID = $firstField['entity_id']; - $hookID = $firstField['custom_group_id']; + $entityID = (int) $firstField['entity_id']; $isMultiple = $firstField['is_multiple']; if (array_key_exists('id', $firstField)) { $sqlOP = "UPDATE $tableName "; @@ -61,8 +60,9 @@ class CRM_Core_BAO_CustomValueTable { $hookOP = 'create'; } - CRM_Utils_Hook::customPre($hookOP, - $hookID, + CRM_Utils_Hook::customPre( + $hookOP, + (int) $firstField['custom_group_id'], $entityID, $fields ); @@ -270,7 +270,7 @@ class CRM_Core_BAO_CustomValueTable { CRM_Core_DAO::executeQuery($query, $params); CRM_Utils_Hook::custom($hookOP, - $hookID, + (int) $firstField['custom_group_id'], $entityID, $fields ); diff --git a/CRM/Utils/Hook.php b/CRM/Utils/Hook.php index f1da9afb10f85c492c4fdc1cf874762eae83ab08..82877f3feb08f5afb0808d7e5cbc726c39e83acf 100644 --- a/CRM/Utils/Hook.php +++ b/CRM/Utils/Hook.php @@ -517,9 +517,9 @@ abstract class CRM_Utils_Hook { * * @param string $op * The type of operation being performed. - * @param string $groupID + * @param int $groupID * The custom group ID. - * @param object $entityID + * @param int $entityID * The entityID of the row in the custom table. * @param array $params * The parameters that were sent into the calling function. @@ -527,7 +527,7 @@ abstract class CRM_Utils_Hook { * @return null * the return value is ignored */ - public static function custom($op, $groupID, $entityID, &$params) { + public static function custom(string $op, int $groupID, int $entityID, &$params) { return self::singleton() ->invoke(['op', 'groupID', 'entityID', 'params'], $op, $groupID, $entityID, $params, self::$_nullObject, self::$_nullObject, 'civicrm_custom'); } @@ -537,9 +537,9 @@ abstract class CRM_Utils_Hook { * * @param string $op * The type of operation being performed. - * @param string $groupID + * @param int $groupID * The custom group ID. - * @param object $entityID + * @param int $entityID * The entityID of the row in the custom table. * @param array $params * The parameters that were sent into the calling function. @@ -547,7 +547,7 @@ abstract class CRM_Utils_Hook { * @return null * the return value is ignored */ - public static function customPre($op, $groupID, $entityID, &$params) { + public static function customPre(string $op, int $groupID, int $entityID, array &$params) { return self::singleton() ->invoke(['op', 'groupID', 'entityID', 'params'], $op, $groupID, $entityID, $params, self::$_nullObject, self::$_nullObject, 'civicrm_customPre'); }