Try to remove group_relationship list cache tags in group_entity_access()

Created on 29 July 2025, 4 days ago

Problem/Motivation

Background: in doing a performance audit for a site with groups module installed, I noticed that their main menu block had several group_relationship_list cache tags on it - the menu almost entirely contains links to nodes. This means the menu block (and dynamic page cache) is added whenever a group relationship is created for any node.

group_entity_access() has the following code:

  // If any new relationship entity is added using any of the retrieved
  // plugins, it might change access.
  $plugin_cache_tags = [];
  foreach ($plugin_ids as $plugin_id) {
    $plugin_cache_tags[] = "group_relationship_list:plugin:$plugin_id";
  }
  $access = AccessResult::neutral()->addCacheTags($plugin_cache_tags);

When saving a relationship for an entity, the cache tags for the entity itself are invalidated, this is also the case after 🐛 Node update hook is triggered upon group content create RTBC .

Given that, I think it should be OK to remove the list cache tags from group_entity_access() entirely, and rely on the invalidation of the entity cache tag instead. This would dramatically improve render cache hit rates on some sites if it's possible.

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

📌 Task
Status

Active

Version

4.0

Component

Code

Created by

🇬🇧United Kingdom catch

Live updates comments and jobs are added and updated live.
  • Performance

    It affects performance. It is often combined with the Needs profiling tag.

Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @catch
  • 🇧🇪Belgium kristiaanvandeneynde Antwerp, Belgium

    One thing I just realized by reading this IS, is that 🐛 Node update hook is triggered upon group content create RTBC did not add list cache tags to its solution.

    So if you had a list of 5 nodes you had access to due to how they were grouped and you lose that access, we are fine because the list was tagged with both the individual nodes' cache tags and node_list. However, if you gain access because a node got added to one of your groups, the list won't show it because we no longer invalidate list cache tags.

    Now, to the issue at hand, hook_entity_access() does not apply to lists, so the facepalm I just had should not get worse if we do as the IS suggests. And as you mentioned, adding or removing an entity from a group will either save the entity (v2/v3) or invalidate its tags (v4). So a main menu block should always get updated when one of the nodes that are actually in the menu have their group status changed.

    So I think you're right and we can completely remove that piece of code.

  • Pipeline finished with Failed
    1 day ago
    Total: 206s
    #562557
  • Pipeline finished with Failed
    1 day ago
    Total: 204s
    #562558
  • 🇬🇧United Kingdom catch

    Put an MR up.

  • Pipeline finished with Success
    1 day ago
    Total: 1148s
    #562564
Production build 0.71.5 2024