diff --git a/CRM/ACL/BAO/ACL.php b/CRM/ACL/BAO/ACL.php index 29b1231940c5..9c7f99f128ac 100644 --- a/CRM/ACL/BAO/ACL.php +++ b/CRM/ACL/BAO/ACL.php @@ -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); @@ -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);