From: Adam Roses Wight Date: Tue, 23 Apr 2013 21:16:28 +0000 (-0700) Subject: Cache CRM_ACL_BAO_ACL::entityTable per-request X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=557f8c173e24f71b2e38bdf9dc0a0b8a0c09cb07;p=civicrm-core.git Cache CRM_ACL_BAO_ACL::entityTable per-request --- diff --git a/CRM/ACL/BAO/ACL.php b/CRM/ACL/BAO/ACL.php index 5cb31b5306..ba54b1d2a7 100644 --- a/CRM/ACL/BAO/ACL.php +++ b/CRM/ACL/BAO/ACL.php @@ -837,7 +837,11 @@ SELECT g.* $aclKeys = array_keys($acls); $aclKeys = implode(',', $aclKeys); - $query = " + $cacheKey = "$tableName-$aclKeys"; + $cache = CRM_Utils_Cache::singleton(); + $ids = $cache->get($cacheKey); + if (!$ids) { + $query = " SELECT a.operation, a.object_id FROM civicrm_acl_cache c, civicrm_acl a WHERE c.acl_id = a.id @@ -847,24 +851,26 @@ SELECT a.operation, a.object_id GROUP BY a.operation,a.object_id ORDER BY a.object_id "; - $params = array(1 => array($tableName, 'String')); - $dao = CRM_Core_DAO::executeQuery($query, $params); - while ($dao->fetch()) { - if ($dao->object_id) { - if (self::matchType($type, $dao->operation)) { - $ids[] = $dao->object_id; + $params = array(1 => array($tableName, 'String')); + $dao = CRM_Core_DAO::executeQuery($query, $params); + while ($dao->fetch()) { + if ($dao->object_id) { + if (self::matchType($type, $dao->operation)) { + $ids[] = $dao->object_id; + } } - } - else { - // this user has got the permission for all objects of this type - // check if the type matches - if (self::matchType($type, $dao->operation)) { - foreach ($allGroups as $id => $dontCare) { - $ids[] = $id; + else { + // this user has got the permission for all objects of this type + // check if the type matches + if (self::matchType($type, $dao->operation)) { + foreach ($allGroups as $id => $dontCare) { + $ids[] = $id; + } } + break; } - break; } + $cache->set($cacheKey, $ids); } }