PHP Error on field settings form when a new condition plugin added but not in the field config yet

Created on 18 August 2022, over 2 years ago
Updated 29 January 2023, almost 2 years ago

Problem/Motivation

When adding a new condition plugin, and trying to add this to the condition field of a custom entity, I saw a php error on the field settings form for editing the condition field settings.

Notice: Undefined index: bhcc_is_portal in Drupal\condition_field\Plugin\Field\FieldType\ConditionFieldItem->fieldSettingsForm() (line 107 of modules/contrib/condition_field/src/Plugin/Field/FieldType/ConditionFieldItem.php).

Looks like $settings['enabled_plugins'][$condition_id] === TRUE expects all conditions avalible to already be part of the field config.
Saving the field settings and exporting the config does fix the error, as it now exports with the new condition plugin.

Steps to reproduce

1. Create a condition field on an entity.
2. Add a module with a new condition plugin (custom or contrib).
3. Go to the field settings form page of the condition field (from the entity manage fields and click edit).
4. PHP error should be visible

Proposed resolution

Check that the condition exists in config before checking is enabled.
I'll see if I can write a patch.

🐛 Bug report
Status

Fixed

Version

2.0

Component

Code

Created by

🇬🇧United Kingdom andybroomfield

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

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.71.5 2024