Can't get permissions for all content from PermissionCache

Kirby

Well-known member
Licensed customer
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

Upvote 0
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.
 
Automated triage: Design issue

Thank you for reporting this issue. The permission cache can preload every content permission for a type, but its public methods only return permissions for one content item at a time. Nothing behaves incorrectly, so this is a missing API method rather than a bug.

This is an automated assessment. A member of staff may review and update it.
 
Back
Top Bottom