From 7a94342fa5e68cbbeecd7b5a07cd49332a59dd11 Mon Sep 17 00:00:00 2001 From: Jon Goldberg Date: Wed, 9 Feb 2022 15:56:11 -0500 Subject: [PATCH] enforce required fields on Contact.duplicatecheck --- api/v3/Contact.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/api/v3/Contact.php b/api/v3/Contact.php index 2b82060958..237d170cfa 100644 --- a/api/v3/Contact.php +++ b/api/v3/Contact.php @@ -1602,10 +1602,16 @@ function _civicrm_api3_contact_getlist_output($result, $request) { * @throws \CiviCRM_API3_Exception */ function civicrm_api3_contact_duplicatecheck($params) { + if (!isset($params['match']) || !is_array($params['match'])) { + throw new \CiviCRM_API3_Exception('Duplicate check must include criteria to check against (missing or invalid $params[\'match\']).'); + } + if (!isset($params['match']['contact_type']) || !is_string($params['match']['contact_type'])) { + throw new \CiviCRM_API3_Exception('Duplicate check must include a contact type. (missing or invalid $params[\'match\'][\'contact_type\'])'); + } $dupes = CRM_Contact_BAO_Contact::getDuplicateContacts( $params['match'], $params['match']['contact_type'], - $params['rule_type'], + $params['rule_type'] ?? '', CRM_Utils_Array::value('exclude', $params, []), CRM_Utils_Array::value('check_permissions', $params), CRM_Utils_Array::value('dedupe_rule_id', $params) -- 2.25.1