mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
BUGFIX: SiteTree::batch_permission_check() doesn't recurse with ID=0 calls
ENHANCEMENT: SiteTree::batch_permission_check() populates its own cache (from r97900) (from r99302) git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@102853 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
e99d56df3f
commit
da2a530274
@ -1084,12 +1084,17 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
||||
// Group $potentiallyInherited by ParentID; we'll look at the permission of all those
|
||||
// parents and then see which ones the user has permission on
|
||||
$siteConfigPermission = SiteConfig::current_site_config()->{$siteConfigMethod}($memberID);
|
||||
$groupedByParent = array();
|
||||
foreach($potentiallyInherited as $item) {
|
||||
if (!isset($groupedByParent[$item->ParentID])) $groupedByParent[$item->ParentID] = array();
|
||||
if ($item->ParentID) $groupedByParent[$item->ParentID][] = $item->ID;
|
||||
else $result[$item->ID] = $siteConfigPermission;
|
||||
if($item->ParentID) {
|
||||
if(!isset($groupedByParent[$item->ParentID])) $groupedByParent[$item->ParentID] = array();
|
||||
$groupedByParent[$item->ParentID][] = $item->ID;
|
||||
} else {
|
||||
$result[$item->ID] = $siteConfigPermission;
|
||||
}
|
||||
}
|
||||
|
||||
if($groupedByParent) {
|
||||
$actuallyInherited = self::batch_permission_check(array_keys($groupedByParent), $memberID, $typeField, $groupJoinTable, $siteConfigMethod);
|
||||
if($actuallyInherited) {
|
||||
$parentIDs = array_keys(array_filter($actuallyInherited));
|
||||
@ -1099,13 +1104,22 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$combinedStageResult = $combinedStageResult + $result;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return isset($combinedStageResult) ? $combinedStageResult : array();
|
||||
if(isset($combinedStageResult)) {
|
||||
// Cache results
|
||||
foreach($combinedStageResult as $id => $val) {
|
||||
self::$cache_permissions[$typeField][$id] = $val;
|
||||
}
|
||||
return $combinedStageResult;
|
||||
} else {
|
||||
array();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user