From 6977178c14bcee9191abcbd28df65f1ea622a456 Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Tue, 16 Feb 2010 01:21:08 +0000 Subject: [PATCH] MINOR adjustments to ensure that the cached permissions were actually hit (from r98835) git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.4@99068 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- core/model/SiteTree.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/core/model/SiteTree.php b/core/model/SiteTree.php index 92c524488..c15dcdcf1 100755 --- a/core/model/SiteTree.php +++ b/core/model/SiteTree.php @@ -997,20 +997,23 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid static function batch_permission_check($ids, $memberID, $typeField, $groupJoinTable, $siteConfigMethod, $globalPermission = 'CMS_ACCESS_CMSMain', $useCached = true) { // Sanitise the IDs $ids = array_filter($ids, 'is_numeric'); + + // This is the name used on the permission cache + // converts something like 'CanEditType' to 'edit'. + $cacheKey = strtolower(substr($typeField, 3, -4)); // Default result: nothing editable $result = array_fill_keys($ids, false); if($ids) { // Look in the cache for values - if($useCached && isset(self::$cache_permissions[$typeField])) { - $cachedValues = array_intersect_key(self::$cache_permissions[$typeField], $result); + if($useCached && isset(self::$cache_permissions[$cacheKey])) { + $cachedValues = array_intersect_key(self::$cache_permissions[$cacheKey], $result); // If we can't find everything in the cache, then look up the remainder separately - $uncachedValues = array_diff_key($result, self::$cache_permissions[$typeField]); + $uncachedValues = array_diff_key($result, self::$cache_permissions[$cacheKey]); if($uncachedValues) { $cachedValues = self::batch_permission_check(array_keys($uncachedValues), $memberID, $typeField, $groupJoinTable, $siteConfigMethod, $globalPermission, false) + $cachedValues; - // $cachedValues = self::can_edit_multiple(array_keys($uncachedValues), $memberID, false) + $cachedValues; } return $cachedValues; }