From 59b8c22428b2d1e7ff224093a3d59330d49dacc1 Mon Sep 17 00:00:00 2001 From: eileen Date: Thu, 25 Mar 2021 12:13:25 +1300 Subject: [PATCH] Only call getGroupACLRoles if contactID is present --- CRM/ACL/BAO/ACL.php | 44 +++++++++++++++++++++----------------------- 1 file changed, 21 insertions(+), 23 deletions(-) diff --git a/CRM/ACL/BAO/ACL.php b/CRM/ACL/BAO/ACL.php index 18bc8023aa..aecd6a40cf 100644 --- a/CRM/ACL/BAO/ACL.php +++ b/CRM/ACL/BAO/ACL.php @@ -47,8 +47,7 @@ class CRM_ACL_BAO_ACL extends CRM_ACL_DAO_ACL { * Array of assoc. arrays of ACL rules * @throws \CRM_Core_Exception */ - protected static function getGroupACLRoles($contact_id) { - $contact_id = CRM_Utils_Type::escape($contact_id, 'Integer'); + protected static function getGroupACLRoles(int $contact_id) { $query = " SELECT acl.* FROM civicrm_acl acl @@ -78,26 +77,6 @@ class CRM_ACL_BAO_ACL extends CRM_ACL_DAO_ACL { $results[$rule->id] = $rule->toArray(); } - // also get all acls for "Any Role" case - // and authenticated User Role if present - $roles = "0"; - $session = CRM_Core_Session::singleton(); - if ($session->get('ufID') > 0) { - $roles .= ",2"; - } - - $query = " -SELECT acl.* - FROM civicrm_acl acl - WHERE acl.entity_id IN ( $roles ) - AND acl.entity_table = 'civicrm_acl_role' -"; - - $rule = CRM_Core_DAO::executeQuery($query); - while ($rule->fetch()) { - $results[$rule->id] = $rule->toArray(); - } - return $results; } @@ -141,8 +120,27 @@ SELECT acl.* while ($rule->fetch()) { $result[$rule->id] = $rule->toArray(); } + $result += self::getGroupACLRoles($contact_id); + } + // also get all acls for "Any Role" case + // and authenticated User Role if present + $roles = '0'; + $session = CRM_Core_Session::singleton(); + if ($session->get('ufID') > 0) { + $roles .= ',2'; + } + + $query = " +SELECT acl.* + FROM civicrm_acl acl + WHERE acl.entity_id IN ( $roles ) + AND acl.entity_table = 'civicrm_acl_role' +"; + + $rule = CRM_Core_DAO::executeQuery($query); + while ($rule->fetch()) { + $result[$rule->id] = $rule->toArray(); } - $result += self::getGroupACLRoles($contact_id); return $result; } -- 2.25.1