From 2d21387cb0f28c76db447ae21ace55aedf8abac9 Mon Sep 17 00:00:00 2001 From: eileen Date: Tue, 15 Jan 2019 12:48:36 +1300 Subject: [PATCH 1/2] Fix mishandling / loss of check_permission flag --- CRM/Dedupe/Finder.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CRM/Dedupe/Finder.php b/CRM/Dedupe/Finder.php index 26d62a3f53a3..ef50af8ed03b 100644 --- a/CRM/Dedupe/Finder.php +++ b/CRM/Dedupe/Finder.php @@ -125,6 +125,7 @@ public static function dupesByParams( if (!$params) { return array(); } + $checkPermission = CRM_Utils_Array::value('check_permission', $params, TRUE); // This may no longer be required - see https://github.com/civicrm/civicrm-core/pull/13176 $params = array_filter($params); @@ -146,7 +147,6 @@ public static function dupesByParams( CRM_Core_Error::fatal("$used rule for $ctype does not exist"); } } - $params['check_permission'] = CRM_Utils_Array::value('check_permission', $params, TRUE); if (isset($params['civicrm_phone']['phone_numeric'])) { $orig = $params['civicrm_phone']['phone_numeric']; @@ -155,7 +155,7 @@ public static function dupesByParams( $rgBao->params = $params; $rgBao->fillTable(); $dao = new CRM_Core_DAO(); - $dao->query($rgBao->thresholdQuery($params['check_permission'])); + $dao->query($rgBao->thresholdQuery($checkPermission)); $dupes = array(); while ($dao->fetch()) { if (isset($dao->id) && $dao->id) { From 7bbd6e3b859511e8c6362ef0c1e179d75819ae6e Mon Sep 17 00:00:00 2001 From: eileen Date: Tue, 15 Jan 2019 13:48:18 +1300 Subject: [PATCH 2/2] Remove foreign key on civicrm_acl_contact_id.user_id. This won't actually remove it from installs - we need to address that separately via ensuring people can and do run the System.updateIndices api call but it removes it from new installs and from tests, hence the test should pass --- CRM/Contact/DAO/ACLContactCache.php | 4 +--- tests/phpunit/CRM/Dedupe/MergerTest.php | 6 ++---- xml/schema/Contact/ACLContactCache.xml | 7 ------- 3 files changed, 3 insertions(+), 14 deletions(-) diff --git a/CRM/Contact/DAO/ACLContactCache.php b/CRM/Contact/DAO/ACLContactCache.php index 1ea72d573b9e..1deee6674ac7 100644 --- a/CRM/Contact/DAO/ACLContactCache.php +++ b/CRM/Contact/DAO/ACLContactCache.php @@ -6,7 +6,7 @@ * * Generated from xml/schema/CRM/Contact/ACLContactCache.xml * DO NOT EDIT. Generated by CRM_Core_CodeGen - * (GenCodeChecksum:4bb9eaae5704bfc98c258aa2f2130f5c) + * (GenCodeChecksum:ab40fa26e037ef4897359d3c288d42b8) */ /** @@ -73,7 +73,6 @@ public function __construct() { public static function getReferenceColumns() { if (!isset(Civi::$statics[__CLASS__]['links'])) { Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__); - Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'user_id', 'civicrm_contact', 'id'); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'contact_id', 'civicrm_contact', 'id'); CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']); } @@ -108,7 +107,6 @@ public static function &fields() { 'entity' => 'ACLContactCache', 'bao' => 'CRM_Contact_DAO_ACLContactCache', 'localizable' => 0, - 'FKClassName' => 'CRM_Contact_DAO_Contact', ], 'contact_id' => [ 'name' => 'contact_id', diff --git a/tests/phpunit/CRM/Dedupe/MergerTest.php b/tests/phpunit/CRM/Dedupe/MergerTest.php index 4ebf200baf77..7f3f03435bdb 100644 --- a/tests/phpunit/CRM/Dedupe/MergerTest.php +++ b/tests/phpunit/CRM/Dedupe/MergerTest.php @@ -795,8 +795,7 @@ public function getStaticCIDRefs() { 0 => 'contact_id', ), 'civicrm_acl_contact_cache' => array( - 0 => 'user_id', - 1 => 'contact_id', + 0 => 'contact_id', ), 'civicrm_action_log' => array( 0 => 'contact_id', @@ -1002,8 +1001,7 @@ public function getCalculatedCIDRefs() { // There might be cleverer ways to do this but it shouldn't change much. $cidRefs['civicrm_contact'][0] = 'primary_contact_id'; $cidRefs['civicrm_contact'][1] = 'employer_id'; - $cidRefs['civicrm_acl_contact_cache'][0] = 'user_id'; - $cidRefs['civicrm_acl_contact_cache'][1] = 'contact_id'; + $cidRefs['civicrm_acl_contact_cache'][0] = 'contact_id'; $cidRefs['civicrm_mailing'][0] = 'created_id'; $cidRefs['civicrm_mailing'][1] = 'scheduled_id'; $cidRefs['civicrm_mailing'][2] = 'approver_id'; diff --git a/xml/schema/Contact/ACLContactCache.xml b/xml/schema/Contact/ACLContactCache.xml index d544de405067..450b56b693eb 100644 --- a/xml/schema/Contact/ACLContactCache.xml +++ b/xml/schema/Contact/ACLContactCache.xml @@ -25,13 +25,6 @@ FK to civicrm_contact (could be null for anon user) 3.1 - - user_id - civicrm_contact
- id - 3.1 - CASCADE -
contact_id Contact ID