From 572f54fa5c589e1630dc7810bd134816d8b545eb Mon Sep 17 00:00:00 2001
From: eileen <emcnaughton@wikimedia.org>
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 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);