Skip to content

Commit

Permalink
CRM-18120 make acl query less debilitating
Browse files Browse the repository at this point in the history
Change-Id: Id95307aeb9abb4ec67c0418d744798abbd666388
  • Loading branch information
eileenmcnaughton committed Oct 14, 2016
1 parent 6819ba0 commit 8f3528a
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 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
WHERE $permission
GROUP BY contact_a.id
ON DUPLICATE KEY UPDATE
user_id=VALUES(user_id),
contact_id=VALUES(contact_id),
operation=VALUES(operation)"
);
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)
AND ac.user_id IS NULL
");
$_processed[$type][$userID] = 1;
}

Expand Down

0 comments on commit 8f3528a

Please sign in to comment.