Skip to content

Commit

Permalink
CRM-18120 make acl query less debilitating
Browse files Browse the repository at this point in the history
  • Loading branch information
eileenmcnaughton committed Oct 14, 2016
1 parent 6819ba0 commit 5c36900
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions CRM/Contact/BAO/Contact/Permission.php
Original file line number Diff line number Diff line change
Expand Up @@ -234,19 +234,14 @@ public static function cache($userID, $type = CRM_Core_Permission::VIEW, $force
$permission = CRM_ACL_API::whereClause($type, $tables, $whereTables, $userID);

$from = CRM_Contact_BAO_Query::fromClause($whereTables);

// FIXME: don't use 'ON DUPLICATE KEY UPDATE'
CRM_Core_DAO::executeQuery("
INSERT INTO civicrm_acl_contact_cache ( user_id, contact_id, operation )
SELECT $userID as user_id, contact_a.id as contact_id, '$operation' as operation
SELECT DISTINCT $userID as user_id, contact_a.id as contact_id, '{$operation}' as operation
$from
LEFT JOIN civicrm_acl_contact_cache ac ON ac.user_id = $userID AND ac.contact_id = contact_a.id AND ac.operation = '{$operation}'
WHERE $permission
GROUP BY contact_a.id
ON DUPLICATE KEY UPDATE
user_id=VALUES(user_id),
contact_id=VALUES(contact_id),
operation=VALUES(operation)"
);
AND ac.user_id IS NULL
");
$_processed[$type][$userID] = 1;
}

Expand Down

0 comments on commit 5c36900

Please sign in to comment.