mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
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:
parent
8bdeeba73e
commit
7c057cbecb
@ -1017,20 +1017,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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user