Computed field definitions created by inheritance have no provider set

Created on 17 January 2024, 10 months ago
Updated 16 February 2024, 9 months ago

Problem/Motivation

The computed field definitions created by field_inheritance_entity_bundle_field_info_alter() do not set a provider (module). If these fields are then used in a Search API index, it causes the search index config to be exported with a dependency on a null module, which in turn causes the following error when the config is imported:

Configuration search_api.index.my_index depends on the "" module that will not be installed after import.

Steps to reproduce

  1. Install the Search API module and configure a search server.
  2. Install Field Inheritance and (for sake of ease of testing) the Recurring Events module.
  3. Add a custom field to default eventseries bundle.
  4. Set up a field inheritance to inherit the custom field onto the default eventinstance bundle using the 'inherit' strategy.
  5. Create a search index for eventinstance entities.
  6. Add the inherited field to the index.
  7. Export the config.

Expected results: The exported search_api.index.my_index.yml should contain values similar to the following:

dependencies:
  config:
    - search_api.server.elasticsearch
  module:
    - recurring_events
    - field_inheritance
    - search_api

and

field_settings:
  my_inherited_field:
    ...
    dependencies:
      module:
        - field_inheritance

Actual results: The config declares dependencies on a null module, like so:

dependencies:
  config:
    - search_api.server.elasticsearch
  module:
    - recurring_events
    - ''
    - search_api

and

field_settings:
  my_inherited_field:
    ...
    dependencies:
      module:
        - null

Proposed resolution

On the $fields[$field->idWithoutTypeAndBundle()] = FieldStorageDefinition::create($type) statement chain, call ->setProvider('field_inheritance').

πŸ› Bug report
Status

Fixed

Version

2.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States muriqui

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024