GroupHeroBlock doesn't have cache context by user group permission

Created on 4 September 2024, 3 months ago
Updated 10 September 2024, 2 months ago

Problem/Motivation

GroupHeroBlock doesn't have cache context by the user group permissons, and when the group admin adds any member to the group with "Group members only (secret)" visibility this block doesn't appear for this member.

Steps to reproduce

  1. Create a group with "Group members only (secret)" visibility
  2. Create a user "Verified" with verified role
  3. Go to the "About" page of the created group as a "Verified" user, and you should see "Access denied"
  4. As a Site manager or Group Admin add a member - "Verified" user
  5. Go to the "About" page of the created group as a "Verified" user, you will see group page but without GroupHeroBlock block
  6. Flash cache - the GroupHeroBlock block will appear

Proposed resolution

Add cache context by user for GroupHeroBlock block:

/**
   * {@inheritDoc}
   */
  public function getCacheContexts(): array {
    return Cache::mergeContexts(parent::getCacheContexts(), [
      'user.group_permissions'
    ]);
  }
πŸ› Bug report
Status

Fixed

Version

13.0

Component

Code (back-end)

Created by

πŸ‡ΊπŸ‡¦Ukraine r_cheh

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

Comments & Activities

Production build 0.71.5 2024