Can't get permissions for all content from PermissionCache

Kirby

Well-known member
Affected version
2.3.6
PermissionCache has a method cacheAllContentPerms() but no corresponding method to get permissions for all content which would be quite useful in some cases.

The attached patch fixes this by adding a new method getAllContentPerms()
 

Attachments

That function can be simplified using the ?? operator:
PHP:
public function getAllContentPerms(int $permissionCombinationId, string $contentType): ?array
{
    if (!isset($this->globalCacheRun[$contentType][$permissionCombinationId]))
    {
        $this->cacheAllContentPerms($permissionCombinationId, $contentType);
    }

    return $this->contentPerms[$permissionCombinationId][$contentType] ?? null;
}

Turns out I have 2 or 3 add-ons which can use this method
 
Last edited:
That function can be simplified using the ?? operator:
Yeah, I basically just copied the isset code from cacheAllContentPerms / getContentPerms without thinking much about optimizing that :D

I've updated the patch.
 
Last edited:
PermissionCache has a method cacheAllContentPerms() but no corresponding method to get permissions for all content which would be quite useful in some cases.
I've backported this to my "Cache permission checks" addon which reworks XF permissions for massively increased permission rebuild speeds and also vastly reduced disk-usage for the permission tables.
 
Back
Top Bottom