Skip to content

Commit

Permalink
Merge pull request #15196 from eileenmcnaughton/dedupe_api
Browse files Browse the repository at this point in the history
dev/core#1230 [Dedupe] Add new api option to getduplicates, permitting a new search to be forced.
  • Loading branch information
mattwire authored Sep 3, 2019
2 parents 2c55712 + c41f68a commit e0b4778
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
7 changes: 5 additions & 2 deletions CRM/Dedupe/Merger.php
Original file line number Diff line number Diff line change
Expand Up @@ -1841,14 +1841,17 @@ public static function createMergeActivities($mainId, $otherId) {
* @param int $searchLimit
* Limit to searching for matches against this many contacts.
*
* @param int $isForceNewSearch
* Should a new search be forced, bypassing any cache retrieval.
*
* @return array
* Array of matches meeting the criteria.
*
* @throws \CRM_Core_Exception
* @throws \CiviCRM_API3_Exception
*/
public static function getDuplicatePairs($rule_group_id, $group_id, $reloadCacheIfEmpty, $batchLimit, $isSelected, $includeConflicts = TRUE, $criteria = [], $checkPermissions = TRUE, $searchLimit = 0) {
$dupePairs = self::getCachedDuplicateMatches($rule_group_id, $group_id, $batchLimit, $isSelected, $includeConflicts, $criteria, $checkPermissions, $searchLimit);
public static function getDuplicatePairs($rule_group_id, $group_id, $reloadCacheIfEmpty, $batchLimit, $isSelected, $includeConflicts = TRUE, $criteria = [], $checkPermissions = TRUE, $searchLimit = 0, $isForceNewSearch = 0) {
$dupePairs = $isForceNewSearch ? [] : self::getCachedDuplicateMatches($rule_group_id, $group_id, $batchLimit, $isSelected, $includeConflicts, $criteria, $checkPermissions, $searchLimit);
if (empty($dupePairs) && $reloadCacheIfEmpty) {
// If we haven't found any dupes, probably cache is empty.
// Try filling cache and give another try. We don't need to specify include conflicts here are there will not be any
Expand Down
6 changes: 5 additions & 1 deletion api/v3/Dedupe.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ function _civicrm_api3_dedupe_getstatistics_spec(&$params) {
*/
function civicrm_api3_dedupe_getduplicates($params) {
$options = _civicrm_api3_get_options_from_params($params);
$dupePairs = CRM_Dedupe_Merger::getDuplicatePairs($params['rule_group_id'], NULL, TRUE, $options['limit'], FALSE, TRUE, $params['criteria'], CRM_Utils_Array::value('check_permissions', $params), CRM_Utils_Array::value('search_limit', $params, 0));
$dupePairs = CRM_Dedupe_Merger::getDuplicatePairs($params['rule_group_id'], NULL, TRUE, $options['limit'], FALSE, TRUE, $params['criteria'], CRM_Utils_Array::value('check_permissions', $params), CRM_Utils_Array::value('search_limit', $params, 0), CRM_Utils_Array::value('is_force_new_search', $params));
return civicrm_api3_create_success($dupePairs);
}

Expand Down Expand Up @@ -184,5 +184,9 @@ function _civicrm_api3_dedupe_getduplicates_spec(&$params) {
'type' => CRM_Utils_Type::T_INT,
'api.default' => (int) Civi::settings()->get('dedupe_default_limit'),
];
$spec['is_force_new_search'] = [
'title' => ts('Force a new search, refreshing any cached search'),
'type' => CRM_Utils_Type::T_BOOLEAN,
];

}

0 comments on commit e0b4778

Please sign in to comment.