Unverified Commit 43076c76 authored by eileen's avatar eileen 🎱 Committed by GitHub

Merge pull request #13475 from civicrm/5.10

5.10 to master
parents 3bf2661b 970511ba
......@@ -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 @@ class CRM_Contact_DAO_ACLContactCache extends CRM_Core_DAO {
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 @@ class CRM_Contact_DAO_ACLContactCache extends CRM_Core_DAO {
'entity' => 'ACLContactCache',
'bao' => 'CRM_Contact_DAO_ACLContactCache',
'localizable' => 0,
'FKClassName' => 'CRM_Contact_DAO_Contact',
],
'contact_id' => [
'name' => 'contact_id',
......
......@@ -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) {
......
......@@ -795,8 +795,7 @@ class CRM_Dedupe_MergerTest extends CiviUnitTestCase {
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 @@ WHERE
// 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';
......
......@@ -681,6 +681,34 @@ class api_v3_ACLPermissionTest extends CiviUnitTestCase {
'id' => $this->scenarioIDs['Contact']['non_permitted_contact'],
'check_permissions' => 1,
], 0);
// Also check that we can access ACLs through a path that uses the acl_contact_cache table.
// historically this has caused errors due to the key_constraint on that table.
// This is a bit of an artificial check as we have to amp up permissions to access this api.
// However, the lower level function is more directly accessed through the Contribution & Event & Profile
$dupes = $this->callAPISuccess('Contact', 'duplicatecheck', [
'match' => [
'first_name' => 'Anthony',
'last_name' => 'Anderson',
'contact_type' => 'Individual',
'email' => 'anthony_anderson@civicrm.org',
],
'check_permissions' => 0,
]);
$this->assertEquals(2, $dupes['count']);
CRM_Core_Config::singleton()->userPermissionClass->permissions = ['administer CiviCRM'];
$dupes = $this->callAPISuccess('Contact', 'duplicatecheck', [
'match' => [
'first_name' => 'Anthony',
'last_name' => 'Anderson',
'contact_type' => 'Individual',
'email' => 'anthony_anderson@civicrm.org',
],
'check_permissions' => 1,
]);
$this->assertEquals(1, $dupes['count']);
}
}
......@@ -25,13 +25,6 @@
<comment>FK to civicrm_contact (could be null for anon user)</comment>
<add>3.1</add>
</field>
<foreignKey>
<name>user_id</name>
<table>civicrm_contact</table>
<key>id</key>
<add>3.1</add>
<onDelete>CASCADE</onDelete>
</foreignKey>
<field>
<name>contact_id</name>
<title>Contact ID</title>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment