Skip to content

FOUR-32256: PERF Reduce duplicate permission queries on menu and auth checks - #8914

Open
gproly wants to merge 4 commits into
developfrom
feature/FOUR-32256
Open

FOUR-32256: PERF Reduce duplicate permission queries on menu and auth checks#8914
gproly wants to merge 4 commits into
developfrom
feature/FOUR-32256

Conversation

@gproly

@gproly gproly commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Description:
Reduce duplicate permission queries on menu and auth checks.

Cache permission names via Permission::cachedNames() and user permission groups via User::cachedPermissionGroups(), with invalidation through PermissionCacheService. Replaces repeated permissions()->pluck('group') and Permission::all() calls in GenerateMenus, User, and AuthServiceProvider.

Going forward: memoize repeated reads per request with once(), batch related data with eager load/preload, and use Cache::remember only for cross-request data with explicit invalidation on writes.

Related tickets:
https://processmaker.atlassian.net/browse/FOUR-32256

ci:package-dynamic-ui:feature/FOUR-32256
ci:package-projects:feature/FOUR-32256
ci:package-savedsearch:feature/FOUR-32256
ci:deploy

…nd add the reason for the delay in the pages mentioned.

Description:
Reduce duplicate permission queries on menu and auth checks.

Cache permission names via Permission::cachedNames() and user permission
groups via User::cachedPermissionGroups(), with invalidation through
PermissionCacheService. Replaces repeated permissions()->pluck('group')
and Permission::all() calls in GenerateMenus, User, and AuthServiceProvider.

Going forward: memoize repeated reads per request with once(), batch
related data with eager load/preload, and use Cache::remember only for
cross-request data with explicit invalidation on writes.

Related tickets:
https://processmaker.atlassian.net/browse/FOUR-32256
@vladyrichter

Copy link
Copy Markdown

QA server K8S was successfully deployed https://ci-0a93bd2386.engk8s.processmaker.net

@pmPaulis pmPaulis changed the title FOUR-32256 [SPIKE] Analisis in the pages mentioned in the IDEA-1400 a… FOUR-32256: PERF Reduce duplicate permission queries on menu and auth checks Jul 23, 2026
@vladyrichter

Copy link
Copy Markdown

QA server K8S was successfully deployed https://ci-0a93bd2386.engk8s.processmaker.net

@vladyrichter

Copy link
Copy Markdown

QA server K8S was successfully deployed https://ci-0a93bd2386.engk8s.processmaker.net

@processmaker-sonarqube

Copy link
Copy Markdown

@vladyrichter

Copy link
Copy Markdown

QA server K8S was successfully deployed https://ci-0a93bd2386.engk8s.processmaker.net

@cursor

cursor Bot commented Sep 8, 2026

Copy link
Copy Markdown

PR Summary

Medium Risk
Changes authorization and menu visibility paths; stale caches could briefly show wrong menu items until invalidation runs, though existing invalidation hooks are extended for the new key.

Overview
Cuts repeated DB hits during menu rendering and gate checks by centralizing permission-name caching and adding per-user permission-group caching.

Permission names now load through Permission::cachedNames() (used by AuthServiceProvider gate registration and administrator hasPermissionsFor), with model save/update/delete invalidating via Cache::forget + rebuild instead of inline Cache::put.

User permission groups are cached for 24h via User::cachedPermissionGroups() and PermissionCacheService::rememberUserPermissionGroups, replacing direct permissions()->pluck('group') in GenerateMenus::userHasPermission for administrators. User permission invalidation now also clears user_permission_groups:{id}.

Unit tests cover that invalidateUserPermissions clears the new groups cache key.

Reviewed by Cursor Bugbot for commit 5ac4c17. Bugbot is set up for automated code reviews on this repo. Configure here.

@decisions-sonarqube

Copy link
Copy Markdown

@nolanpro

nolanpro commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

QA server K8S was successfully deployed https://ci-0a93bd2386.engk8s.processmaker.net

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants