* @param bool $checkPermissions
* Respect logged in user permissions.
*
+ * @param int $limit
+ * Optional limit. This limits the number of contacts for which the code will
+ * attempt to find matches.
+ *
* @return array
* Array of (cid1, cid2, weight) dupe triples
- * @throws \Exception
+ *
+ * @throws CiviCRM_API3_Exception
+ * @throws Exception
*/
public static function dupes($rgid, $cids = array(), $checkPermissions = TRUE, $limit = NULL) {
$rgBao = new CRM_Dedupe_BAO_RuleGroup();
* @throws \CiviCRM_API3_Exception
*/
function civicrm_api3_job_process_batch_merge($params) {
- $rule_group_id = CRM_Utils_Array::value('rgid', $params);
+ $rule_group_id = CRM_Utils_Array::value('rule_group_id', $params);
if (!$rule_group_id) {
$rule_group_id = civicrm_api3('RuleGroup', 'getvalue', array(
'contact_type' => 'Individual',
'used' => 'Unsupervised',
'return' => 'id',
+ 'options' => array('limit' => 1),
));
}
$gid = CRM_Utils_Array::value('gid', $params);
* @param $params
*/
function _civicrm_api3_job_process_batch_merge_spec(&$params) {
- $params['rgid'] = array(
+ $params['rule_group_id'] = array(
'title' => 'Dedupe rule group id, defaults to Contact Unsupervised rule',
'type' => CRM_Utils_Type::T_INT,
+ 'api.aliases' => array('rgid'),
);
$params['gid'] = array(
'title' => 'group id',
), 4);
}
+ /**
+ * Test the batch merge does not fatal on an empty rule.
+ *
+ * @dataProvider getRuleSets
+ *
+ * @param string $contactType
+ * @param string $used
+ * @param bool $isReserved
+ * @param int $threshold
+ */
+ public function testBatchMergeEmptyRule($contactType, $used, $name, $isReserved, $threshold) {
+ $ruleGroup = $this->callAPISuccess('RuleGroup', 'create', array(
+ 'contact_type' => $contactType,
+ 'threshold' => $threshold,
+ 'used' => $used,
+ 'name' => $name,
+ 'is_reserved' => $isReserved,
+ ));
+ $this->callAPISuccess('Job', 'process_batch_merge', array('rule_group_id' => $ruleGroup['id']));
+ $this->callAPISuccess('RuleGroup', 'delete', array('id' => $ruleGroup['id']));
+ }
+
+ /**
+ * Get the various rule combinations.
+ */
+ public function getRuleSets() {
+ $contactTypes = array('Individual', 'Organization', 'Household');
+ $useds = array('Unsupervised', 'General', 'Supervised');
+ $ruleGroups = array();
+ foreach ($contactTypes as $contactType) {
+ foreach ($useds as $used) {
+ $ruleGroups[] = array($contactType, $used, 'Bob', FALSE, 0);
+ $ruleGroups[] = array($contactType, $used, 'Bob', FALSE, 10);
+ $ruleGroups[] = array($contactType, $used, 'Bob', TRUE, 10);
+ $ruleGroups[] = array($contactType, $used, $contactType . $used, FALSE, 10);
+ $ruleGroups[] = array($contactType, $used, $contactType . $used, TRUE, 10);
+ }
+ }
+ return $ruleGroups;
+ }
+
/**
* Test the batch merge does not create duplicate emails.
*