Merge pull request #18748 from eileenmcnaughton/log
[civicrm-core.git] / CRM / ACL / BAO / ACL.php
index 873e6d55b7a7632900408e0d2b1eddb102c4e3f3..f1f8cb0df8a1c67f51fb2bc348cde8620f1d7dad 100644 (file)
@@ -204,8 +204,6 @@ SELECT      acl.*
   protected static function getGroupACLRoles($contact_id) {
     $contact_id = CRM_Utils_Type::escape($contact_id, 'Integer');
 
-    $rule = new CRM_ACL_BAO_ACL();
-
     $query = "   SELECT          acl.*
                         FROM            civicrm_acl acl
                         INNER JOIN      civicrm_option_group og
@@ -228,7 +226,7 @@ SELECT      acl.*
 
     $results = [];
 
-    $rule->query($query);
+    $rule = CRM_Core_DAO::executeQuery($query);
 
     while ($rule->fetch()) {
       $results[$rule->id] = $rule->toArray();
@@ -249,7 +247,7 @@ SELECT acl.*
    AND acl.entity_table   = 'civicrm_acl_role'
 ";
 
-    $rule->query($query);
+    $rule = CRM_Core_DAO::executeQuery($query);
     while ($rule->fetch()) {
       $results[$rule->id] = $rule->toArray();
     }
@@ -479,10 +477,10 @@ SELECT g.*
       $aclKeys = array_keys($acls);
       $aclKeys = implode(',', $aclKeys);
 
-      $cacheKey = CRM_Utils_Cache::cleanKey("$tableName-$aclKeys");
+      $cacheKey = CRM_Utils_Cache::cleanKey("$type-$tableName-$aclKeys");
       $cache = CRM_Utils_Cache::singleton();
       $ids = $cache->get($cacheKey);
-      if (!$ids) {
+      if (!is_array($ids)) {
         $ids = [];
         $query = "
 SELECT   a.operation, a.object_id
@@ -520,6 +518,8 @@ ORDER BY a.object_id
     if (empty($ids) && !empty($includedGroups) &&
       is_array($includedGroups)
     ) {
+      // This is pretty alarming - we 'sometimes' include all included groups
+      // seems problematic per https://lab.civicrm.org/dev/core/-/issues/1879
       $ids = $includedGroups;
     }
     if ($contactID) {