Error: Call to a member function getAllowedBundles() on null

Created on 2 July 2024, 5 months ago

Problem/Motivation

The ListItemProcessor plugin includes the following comment and code:

    // If it's an entity base field, we find it in the field definitions.
    // We don't have access to the bundle via SearchApiFacetSourceInterface, so
    // we check the entity's base fields only.
    $base_fields = $this->entityFieldManager->getFieldDefinitions($entity, '');

However, the code documentation for that method in core states: "Gets the field definitions for a specific bundle."

Additionally, there is a method in core to get the base field definitions: getBaseFieldDefinitions($entity_type_id).

I can provide steps to reproduce, if needed. We are using the collection module, and have created a search index and facets block that uses the label instead of the value for the block rendering. See https://www.drupal.org/project/collection/issues/3458552 πŸ› Error: Call to a member function getAllowedBundles() on null in collection_entity_bundle_field_info() Active .

Proposed resolution

Swap line 119 to use getBaseFieldDefinitions instead of getFieldDefinitions.

πŸ› Bug report
Status

Active

Version

3.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States a-fro

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