class CRM_Dedupe_Finder

The CiviCRM duplicate discovery engine is based on an algorithm designed by David Strauss david@fourkitchens.com.

Methods

static array
dupes(int $rgid, array $cids = array(), bool $checkPermissions = TRUE, int $limit = NULL)

Return a contact_id-keyed array of arrays of possible dupes (of the key contact_id) - limited to dupes of $cids if provided.

static array
dupesByParams(array $params, string $ctype, string $used = 'Unsupervised', array $except = array(), int $ruleGroupID = NULL)

Return an array of possible dupes, based on the provided array of params, using the default rule group for the given contact type and usage.

static array
dupesInGroup(int $rgid, int $gid, int $limit = NULL)

Return a contact_id-keyed array of arrays of possible dupes in the given group.

static array
formatParams(array $fields, string $ctype)

A hackish function needed to massage CRM_Contact_Form_$ctype::formRule() object into a valid $params array for dedupe

static array
parseAndStoreDupePairs(array $foundDupes, string $cacheKeyString)

Parse duplicate pairs into a standardised array and store in the prev_next_cache.

Details

at line 64
static array dupes(int $rgid, array $cids = array(), bool $checkPermissions = TRUE, int $limit = NULL)

Return a contact_id-keyed array of arrays of possible dupes (of the key contact_id) - limited to dupes of $cids if provided.

Parameters

int $rgid Rule group id.
array $cids Contact ids to limit the search to.
bool $checkPermissions Respect logged in user permissions.
int $limit Optional limit. This limits the number of contacts for which the code will attempt to find matches.

Return Value

array Array of (cid1, cid2, weight) dupe triples

Exceptions

CiviCRM_API3_Exception
Exception

at line 116
static array dupesByParams(array $params, string $ctype, string $used = 'Unsupervised', array $except = array(), int $ruleGroupID = NULL)

Return an array of possible dupes, based on the provided array of params, using the default rule group for the given contact type and usage.

check_permission is a boolean flag to indicate if permission should be considered. default is to always check permissioning but public pages for example might not want permission to be checked for anonymous users. Refer CRM-6211. We might be beaking Multi-Site dedupe for public pages.

Parameters

array $params Array of params of the form $params[$table][$field] == $value.
string $ctype Contact type to match against.
string $used Dedupe rule group usage ('Unsupervised' or 'Supervised' or 'General').
array $except Array of contacts that shouldn't be considered dupes.
int $ruleGroupID The id of the dedupe rule we should be using.

Return Value

array matching contact ids

at line 174
static array dupesInGroup(int $rgid, int $gid, int $limit = NULL)

Return a contact_id-keyed array of arrays of possible dupes in the given group.

Parameters

int $rgid Rule group id.
int $gid Contact group id (currently, works only with non-smart groups).
int $limit

Return Value

array array of (cid1, cid2, weight) dupe triples

at line 194
static array formatParams(array $fields, string $ctype)

A hackish function needed to massage CRM_Contact_Form_$ctype::formRule() object into a valid $params array for dedupe

Parameters

array $fields Contact structure from formRule().
string $ctype Contact type of the given contact.

Return Value

array valid $params array for dedupe

at line 324
static array parseAndStoreDupePairs(array $foundDupes, string $cacheKeyString)

Parse duplicate pairs into a standardised array and store in the prev_next_cache.

Parameters

array $foundDupes
string $cacheKeyString

Return Value

array Dupe pairs with the keys Dupe pairs with the keys -srcID -srcName -dstID -dstName -weight -canMerge

Exceptions

CRM_Core_Exception