Responses to ->getSetting() ignore requested setting string, static return value.

Created on 29 June 2023, over 1 year ago
Updated 9 July 2023, over 1 year ago

Problem/Motivation

I'm using this module and the Reverse Entity Reference plugin it comes with. The node type with the Computed field on it uses Layout Builder. When I place a block using this field to render the referenced entity in a layout, Layout builder whitescreens the next time I come to edit it.

I tracked this down to a bad response from the plugin to ->getSetting($setting) requests. The ComputedFieldDefinition class calls `getFieldDefinitionSetting($setting)` on the plugin. The comment above indicates it is so the plugin can get first dibs before the computedFieldDefinition class gives its own answer.

The code for `getFieldDefinitionSettings($setting)` is very weird. It disregards the argument and just returns the string identifying the type of entity the field can reference.

That's a sensible response when "$setting" is "target_type". In every other case, this answer is incoherent.

This "bad" answer causes issues with layout builder when it requests other settings from the plugin.

Steps to reproduce

Set up some reverse entity reference fields on a node and configure it to use layout builder. Render your reversed entity in the layout.

Proposed resolution

Return appropriate responses based on the argument passed into the function. Return NULL if we don't know how to respond.

API changes

This will change the behavior of this function, so if anything is relying on getting the weird array answer that could be an issue.

πŸ› Bug report
Status

Fixed

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

Production build 0.71.5 2024