Skip to content

perf(acl): share one ACLManager per user per request#4744

Open
solracsf wants to merge 1 commit into
masterfrom
fix/acl-manager-factory-memoize
Open

perf(acl): share one ACLManager per user per request#4744
solracsf wants to merge 1 commit into
masterfrom
fix/acl-manager-factory-memoize

Conversation

@solracsf

@solracsf solracsf commented Jun 4, 2026

Copy link
Copy Markdown
Member

Fix #4740

ACLManagerFactory::getACLManager() created a fresh ACLManager (and a fresh empty rule cache) on every call, so preloadRulesForFolder() warmed a cache that was immediately discarded and the per-item permission checks
ran on different instances that never saw it.

Memoize the manager by UID. Since the factory is request-scoped, all callers now share one rule cache per user, so cache warming and the subsequent lookups actually hit the same cache.

Because the cache is now shared across all of a user's folders, scope its keys by storage id. Paths are only unique within a storage (folders using a separate storage start over at "files/..."), so a path-only key could
otherwise return one storage's rules for a same-named path in another.

Tests:

  • ACLManagerFactoryTest: same UID returns the same instance; different UIDs return different instances.
  • ACLManagerTest::testRuleCacheIsScopedPerStorage: the same relative path under two storage ids resolves with each storage's own rules (no cross-storage cache collision).

@solracsf solracsf force-pushed the fix/acl-manager-factory-memoize branch 3 times, most recently from 5c82f56 to b508f8c Compare June 4, 2026 15:01
@solracsf solracsf added 3. to review Items that need to be reviewed performance πŸš€ labels Jun 4, 2026
Comment thread lib/ACL/ACLManagerFactory.php Outdated
Signed-off-by: Git'Fellow <12234510+solracsf@users.noreply.github.com>
@solracsf solracsf force-pushed the fix/acl-manager-factory-memoize branch from b508f8c to ba506ca Compare June 4, 2026 15:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3. to review Items that need to be reviewed performance πŸš€

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ACL rule cache: preload is orphaned because a new ACLManager (and a new cache) is created per call

2 participants