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

Created on 2 July 2024, 5 months ago
Updated 9 July 2024, 5 months ago

This error cropped up while updating some facets search block settings to display the label of a list item rather than the value.

The reason for this is that the build() method of Drupal\facets\Plugin\facets\processor\ListItemProcessor includes the following comment and call:

    // 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, '');

We could work around this by ensuring that a bundle is passed, but perhaps a better approach is to open a ticket in the facets module requesting that they call getBaseFieldDefinitions($entity_type_id), which appears to be a more robust approach than calling getFieldDefinitions($entity_type_id, $bundle), which is documented to "Gets the field definitions for a specific bundle."

🐛 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

Comments & Activities

Production build 0.71.5 2024