MINOR adjustments to ensure that the cached permissions were actually hit (from r98835) (from r99068)

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@102835 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Ingo Schommer 2010-04-14 03:59:54 +00:00
parent 8bdeeba73e
commit 7c057cbecb

View File

@ -1018,19 +1018,22 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
// 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;
}