Cache metadata by plugins is discarded

Created on 29 July 2022, almost 2 years ago
Updated 19 March 2024, 3 months ago

Problem/Motivation

The Field Permissions module relies on hook_entity_field_access() to forbid access to fields. The access result is determined by the \Drupal\field_permissions\FieldPermissionsService::getFieldAccess() method. However, this access result only allows for TRUE/FALSE return values. As a result, custom plugins that conditionally forbid access cannot pass the necessary cache context to the access result. The cached result is then applied for subsequent users, resulting in an incorrect behaviour.

Proposed resolution

Pass any cache metadata from the plugin getFieldAccess to the field_permissions_entity_field_access AccessResult.

Remaining tasks

  1. Write a patch
  2. Review
  3. Commit

User interface changes

None.

API changes

FieldPermissionType plugins must return an AccessResult

Data model changes

FieldPermissionType plugins hasFieldAccess method must return an AccessResult

🐛 Bug report
Status

Needs review

Version

1.0

Component

Code

Created by

🇳🇱Netherlands idebr

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

Merge Requests

Comments & Activities

Not all content is available!

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

Production build 0.69.0 2024