It turned out the toggleDuplicates was not working when criteria was set as the validation rule didn't work.
Passing around cacheKey
is easier to validate and we know the cache willbe created at the point of toggle. Use cacheKey instead
in url
* Mark dupe pairs as selected from un-selected state or vice-versa, in dupe cache table.
*/
public static function toggleDedupeSelect() {
- $rgid = CRM_Utils_Type::escape($_REQUEST['rgid'], 'Integer');
- $gid = CRM_Utils_Type::escape($_REQUEST['gid'], 'Integer');
$pnid = $_REQUEST['pnid'];
$isSelected = CRM_Utils_Type::escape($_REQUEST['is_selected'], 'Boolean');
- $criteria = CRM_Utils_Request::retrieve('criteria', 'Json', $null, FALSE, '{}');
-
- $cacheKeyString = CRM_Dedupe_Merger::getMergeCacheKeyString($rgid, $gid, json_decode($criteria, TRUE));
+ $cacheKeyString = CRM_Utils_Request::retrieve('cacheKey', 'Alphanumeric', $null, FALSE);
$params = array(
1 => array($isSelected, 'Boolean'),
$this->assign('urlQuery', CRM_Utils_System::makeQueryString($urlQry));
$this->assign('isSelected', $this->isSelected());
$criteria = json_decode($criteria, TRUE);
+ $cacheKeyString = CRM_Dedupe_Merger::getMergeCacheKeyString($rgid, $gid, $criteria);
+ $this->assign('cacheKey', $cacheKeyString);
if ($context == 'search') {
$context = 'search';
if ($action & CRM_Core_Action::RENEW) {
// empty cache
if ($rgid) {
- CRM_Core_BAO_PrevNextCache::deleteItem(NULL, CRM_Dedupe_Merger::getMergeCacheKeyString($rgid, $gid, $criteria));
+ CRM_Core_BAO_PrevNextCache::deleteItem(NULL, $cacheKeyString);
}
$urlQry['action'] = 'update';
CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/contact/dedupefind', $urlQry));
$this->assign('sourceUrl', CRM_Utils_System::url('civicrm/ajax/dedupefind', $urlQry, FALSE, NULL, FALSE));
- //reload from cache table
- $cacheKeyString = CRM_Dedupe_Merger::getMergeCacheKeyString($rgid, $gid, $criteria);
-
$stats = CRM_Dedupe_Merger::getMergeStats($cacheKeyString);
if ($stats) {
$message = CRM_Dedupe_Merger::getMergeStatsMsg($stats);
*/
public static function getMergeCacheKeyString($rule_group_id, $group_id, $criteria = array(), $checkPermissions = TRUE) {
$contactType = CRM_Dedupe_BAO_RuleGroup::getContactTypeForRuleGroup($rule_group_id);
- $cacheKeyString = "merge {$contactType}";
+ $cacheKeyString = "merge_{$contactType}";
$cacheKeyString .= $rule_group_id ? "_{$rule_group_id}" : '_0';
$cacheKeyString .= $group_id ? "_{$group_id}" : '_0';
$cacheKeyString .= !empty($criteria) ? md5(serialize($criteria)) : '_0';
var is_selected = CRM.$('.crm-dedupe-select-all').prop('checked') ? 1 : 0;
}
- var criteria = {/literal}'{$criteria|escape}'{literal};
- criteria = criteria.length > 0 ? criteria : 0;
+ var cacheKey = {/literal}'{$cacheKey|escape}'{literal};
var dataUrl = {/literal}"{crmURL p='civicrm/ajax/toggleDedupeSelect' h=0 q='snippet=4'}"{literal};
var rgid = {/literal}"{$rgid}"{literal};
rgid = rgid.length > 0 ? rgid : 0;
gid = gid.length > 0 ? gid : 0;
- CRM.$.post(dataUrl, {pnid: id, rgid: rgid, gid: gid, is_selected: is_selected, criteria : criteria}, function (data) {
+ CRM.$.post(dataUrl, {pnid: id, rgid: rgid, gid: gid, is_selected: is_selected, cacheKey : cacheKey}, function (data) {
// nothing to do for now
}, 'json');
}