Skip to content

Commit

Permalink
[REF] Only call getACLs when contact_id is present, remove handling
Browse files Browse the repository at this point in the history
getACLs is called from one place in the code. Within the function there are 2 places that
handle the possibility it might be null - this moves it to the calling function
& requires contact id to be an int
  • Loading branch information
eileenmcnaughton authored and magnolia61 committed Mar 3, 2020
1 parent e870ad8 commit 572f54f
Showing 1 changed file with 7 additions and 14 deletions.
21 changes: 7 additions & 14 deletions CRM/ACL/BAO/ACL.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,27 +155,18 @@ public function toArray($format = '%s', $hideEmpty = FALSE) {
*
* @throws \CRM_Core_Exception
*/
protected static function getACLs($contact_id = NULL) {
protected static function getACLs(int $contact_id) {
$results = [];

if (empty($contact_id)) {
return $results;
}

$contact_id = CRM_Utils_Type::escape($contact_id, 'Integer');

$rule = new CRM_ACL_BAO_ACL();

$acl = self::getTableName();
$contact = CRM_Contact_BAO_Contact::getTableName();

$query = " SELECT acl.*
FROM $acl acl";

if (!empty($contact_id)) {
$query .= " WHERE acl.entity_table = '$contact'
AND acl.entity_id = $contact_id";
}
FROM $acl acl
WHERE acl.entity_table = '$contact'
AND acl.entity_id = $contact_id";

$rule->query($query);

Expand Down Expand Up @@ -358,7 +349,9 @@ public static function getAllByContact($contact_id) {
$result = [];

/* First, the contact-specific ACLs, including ACL Roles */
$result += self::getACLs($contact_id);
if ($contact_id) {
$result += self::getACLs((int) $contact_id);
}

/* Then, all ACLs granted through group membership */
$result += self::getGroupACLs($contact_id, TRUE);
Expand Down

0 comments on commit 572f54f

Please sign in to comment.