Fix mishandling / loss of check_permission flag
authoreileen <emcnaughton@wikimedia.org>
Mon, 14 Jan 2019 23:48:36 +0000 (12:48 +1300)
committereileen <emcnaughton@wikimedia.org>
Tue, 15 Jan 2019 08:30:58 +0000 (21:30 +1300)
CRM/Dedupe/Finder.php
tests/phpunit/api/v3/ACLPermissionTest.php

index 26d62a3f53a39eb7317325434375420b11bc5e7b..ef50af8ed03bf72809ad20e19b2c9686e858b94c 100644 (file)
@@ -125,6 +125,7 @@ class CRM_Dedupe_Finder {
     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 @@ class CRM_Dedupe_Finder {
         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 @@ class CRM_Dedupe_Finder {
     $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) {
index 73ffd354efecae8f365a39f3e372158c4125789f..b45a11d0fb3eba93d40347f07c0fe81ccfa9744b 100644 (file)
@@ -692,9 +692,7 @@ class api_v3_ACLPermissionTest extends CiviUnitTestCase {
       ],
       'check_permissions' => 0,
     ]);
-    // Actually this should be 2 but there is a line of array_filter in dupesByParams that causes
-    // check_permissions to be dropped at that point. I am working aginst rc now - that should possibly be removed against master.
-    $this->assertEquals(1, $dupes['count']);
+    $this->assertEquals(2, $dupes['count']);
     CRM_Core_Config::singleton()->userPermissionClass->permissions = ['administer CiviCRM'];
 
     $dupes = $this->callAPISuccess('Contact', 'duplicatecheck', [