Problem/Motivation
TypeError: Unsupported operand types: array + null in Drupal\field_ui\Form\EntityViewDisplayEditForm->Drupal\field_ui\Form\{closure}() (line 166 of core/modules/field_ui/src/Form/EntityViewDisplayEditForm.php).
The actual issue is coming from the Linked Field module, however, this should be better handled. From what I can see in the code they were close.
Steps to reproduce
- Install and enable 'linked_field' module
- Add a 'link' field to an entity type
- Go to entity types manage display
- Presto!!
Proposed resolution
Change:
$settings_form[$module] = ($settings_form[$module] ?? []) + ($hook(
$plugin,
$field_definition,
$this->entity->getMode(),
$form,
$form_state,
)) ?? [];
to:
$settings_form[$module] = ($settings_form[$module] ?? []) + ($hook(
$plugin,
$field_definition,
$this->entity->getMode(),
$form,
$form_state,
) ?? []);
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | field-ui--unsupported-operand-types--3552531-2.patch | 572 bytes | cbstuart |
Issue fork drupal-3552531
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
- 3552531--unsupported-operand
changes, plain diff MR !13611
Comments
Comment #2
cbstuart commentedComment #3
cbstuart commentedComment #4
cbstuart commentedComment #5
cilefen commentedComment #6
awasson commentedYes, the resolution proposed by @cbstuart resolves the issue.
Comment #8
vitaliyb98 commentedAlso received this error. Provided solution works for me.
Comment #9
cilefen commentedSo there is a subtle syntax bug here. Can we get an automated test that triggers the bug?
Comment #10
awasson commentedI'm bumping this to Major as it makes it impossible to administrate production websites without patching (not possible on some hosts like Pantheon). I would bump to critical but that's just my particular situation.
EDIT: For clarification, by Major, I mean that none of my Display settings are available for content or paragraphs.
The fix that has been proposed does prevent the issue.
Cheers,
Andrew
Comment #11
awasson commented@cilefen, are you suggesting that the proposed fix introduces a subtle syntax bug? I'm trying to identify where it exists.
Where the existing code positions the null coalescing operator positioned leads to the TypeError mentioned. The updated version ensures that:
1) If $settings_form[$module] is not set, it defaults to an empty array
2) If the $hook() method call returns null, it's replaced with an empty array
3) The arrays are then safely merged using the + operator
I must have missed something. Can you elaborate so we can get this resolved?
Cheers,
Andrew
Comment #13
tobiasbJust try:
Fatal error:
Fixed:
Comment #14
astonvictor commented[ignore]
Comment #15
astonvictor commentedComment #17
ankitv18 commentedRebasing the MR make the pipeline pass.
changes are quite straightforward, hence moving into RTBC
Comment #21
catchCommitted/pushed to 11.x and cherry-picked to 11.3.x, thanks!