From: eileen Date: Wed, 24 Mar 2021 23:13:25 +0000 (+1300) Subject: Only call getGroupACLRoles if contactID is present X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=59b8c22428b2d1e7ff224093a3d59330d49dacc1;p=civicrm-core.git Only call getGroupACLRoles if contactID is present --- 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; }