mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
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
This commit is contained in:
parent
530b943dae
commit
6977178c14
@ -998,19 +998,22 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
// Sanitise the IDs
|
// Sanitise the IDs
|
||||||
$ids = array_filter($ids, 'is_numeric');
|
$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
|
// Default result: nothing editable
|
||||||
$result = array_fill_keys($ids, false);
|
$result = array_fill_keys($ids, false);
|
||||||
if($ids) {
|
if($ids) {
|
||||||
|
|
||||||
// Look in the cache for values
|
// Look in the cache for values
|
||||||
if($useCached && isset(self::$cache_permissions[$typeField])) {
|
if($useCached && isset(self::$cache_permissions[$cacheKey])) {
|
||||||
$cachedValues = array_intersect_key(self::$cache_permissions[$typeField], $result);
|
$cachedValues = array_intersect_key(self::$cache_permissions[$cacheKey], $result);
|
||||||
|
|
||||||
// If we can't find everything in the cache, then look up the remainder separately
|
// 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) {
|
if($uncachedValues) {
|
||||||
$cachedValues = self::batch_permission_check(array_keys($uncachedValues), $memberID, $typeField, $groupJoinTable, $siteConfigMethod, $globalPermission, false) + $cachedValues;
|
$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;
|
return $cachedValues;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user