Incompatible with Field Permissions module

Created on 23 June 2023, over 1 year ago
Updated 25 June 2023, over 1 year ago

Problem/Motivation

I'm trying to use the module on a site that also has the field permissions module. For some reason, Field Permissions module very deliberately invokes "isDisplayConfigurable()" on fields with "display" as the context. They even deliberately change it from "view" to "display".

Due to the use of "match" in ComputedField::isDisplayConfigurable(), this means the PHP crashes when the unexpected "display" context is passed along -- we only have "match" options for "view" and "form".

Those options match the Interface's documentation, so maybe this is a field_permissions bug, but it's easy to fix here with a slightly less picky implementation of isDisplayConfigurable().

Steps to reproduce

Enable field_permissions module for an entity, create a reverse entity reference comptued field, render it on your page.

Proposed resolution

Don't use "match".

πŸ› Bug report
Status

Closed: works as designed

Version

4.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States gcb

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

Comments & Activities

  • Issue created by @gcb
  • πŸ‡ΊπŸ‡ΈUnited States gcb

    Here's a basic patch that resolves the issue.

  • Status changed to Closed: works as designed over 1 year ago
  • πŸ‡¬πŸ‡§United Kingdom joachim

    The bug is in the other module.

    The docs say:

      /**
       * Returns whether the display for the field can be configured.
       *
       * @param string $display_context
       *   The display context. Either 'view' or 'form'.
       *
       * @return bool
       *   TRUE if the display for this field is configurable in the given context.
       *   If TRUE, the display options returned by getDisplayOptions() may be
       *   overridden via the respective entity display.
       *
       * @see \Drupal\Core\Entity\Display\EntityDisplayInterface
       */
      public function isDisplayConfigurable($display_context);
    
Production build 0.71.5 2024