Skip to content

[6.x] Speed up permission checks - #15773

Merged
duncanmcclean merged 1 commit into
6.xfrom
cache-permission-values
Nov 2, 2026
Merged

duncanmcclean merged 1 commit into
6.xfrom
cache-permission-values

Conversation

@duncanmcclean

Copy link
Copy Markdown
Member

This pull request speeds up permission checks by caching the values of the flattened permissions.

Statamic's Gate::after callback checks whether an ability is a Statamic permission before getting involved. To do that, it mapped every flattened permission (~475 of them) to its value on every single gate check.

#12258 already caches the flattened permissions, so this PR caches their values in a lookup alongside them, via a new Permissions::contains() method. The values come from the same cached, flattened permissions, so the result of every check is the same as before. It's just quicker to get to.

On an entry where the publish form makes ~2,300 permission checks (mostly from Assets fields), this saved ~190ms.

Related: #12258
Related: #13385

@duncanmcclean
duncanmcclean merged commit d573ee2 into 6.x Nov 2, 2026
65 checks passed
@duncanmcclean
duncanmcclean deleted the cache-permission-values branch November 2, 2026 17:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant