From 2ee636aa9e6a0747cf765664799ab27ee92a4c62 Mon Sep 17 00:00:00 2001 From: eileen Date: Mon, 2 Mar 2020 11:50:22 +1300 Subject: [PATCH] [REF] Only call getACLs when contact_id is present, remove handling 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 --- CRM/ACL/BAO/ACL.php | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/CRM/ACL/BAO/ACL.php b/CRM/ACL/BAO/ACL.php index 29b1231940..9c7f99f128 100644 --- a/CRM/ACL/BAO/ACL.php +++ b/CRM/ACL/BAO/ACL.php @@ -155,27 +155,18 @@ class CRM_ACL_BAO_ACL extends CRM_ACL_DAO_ACL { * * @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); @@ -358,7 +349,9 @@ SELECT acl.* $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); -- 2.25.1