Add cache to menu access check

Created on 9 October 2025, 13 days ago

Problem/Motivation

Group Content Menu blocks can cause performance degradation on sites with multiple groups.
The GroupOwnsMenuContentAccessChecker::access() method performs uncached loadByEntity() database queries on every menu access check, which can result in long page load times for first-time visitors.

Steps to reproduce

  1. Create a site with multiple groups and group content menus
  2. Add group menu blocks to page layouts
  3. Clear all caches
  4. Load any page as an anonymous user
  5. Observe load times

Proposed resolution

Add a caching layer (GroupContentMenuAccessCache service) for group relationship lookups in GroupOwnsMenuContentAccessChecker.
Cache loadByEntity() results with proper cache tags (group:{id}, group_menu:{id}, user.permissions) for automatic invalidation when content changes.

Remaining tasks

- Review of proposed patch
- Performance testing on various site configurations

User interface changes

None

API changes

None

Data model changes

None

Feature request
Status

Active

Version

3.0

Component

Code

Created by

🇬🇧United Kingdom the_g_bomb

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

No activities found.

Production build 0.71.5 2024