CiviCRM entity is missing bundle

Created on 12 February 2024, 11 months ago
Updated 9 May 2024, 8 months ago

Problem/Motivation

When viewing CiviCRM entity display settings (/admin/structure/civicrm-entity/{BUNDLE)/display) I get the error:

Attempt to create a base field bundle override of field {FIELD} without a bundle in Drupal\Core\Field\Entity\BaseFieldOverride->__construct() (line 112 of core/lib/Drupal/Core/Field/Entity/BaseFieldOverride.php).

Following the stack trace I see that the addtocalendar module does:

if ($field_definition instanceof BaseFieldDefinition) {
  $field_definition = $field_definition->getConfig($field_definition->getTargetBundle());
}

And this is what leads to the exception getting triggered.

Steps to reproduce

Edit a CiviCRM entity and go to the "Manage Display" tab.
Maybe have the addtocalendar module enabled?

Alternatively just call $field_definition->getConfig on the CiviCrm entities fields.

Proposed resolution

I can fix it by altering the civicrm_entity_entity_bundle_field_info function.

πŸ› Bug report
Status

Fixed

Version

4.0

Component

Code

Created by

πŸ‡¬πŸ‡§United Kingdom dahousecat

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

Comments & Activities

  • Issue created by @dahousecat
  • πŸ‡¬πŸ‡§United Kingdom dahousecat
  • πŸ‡ΊπŸ‡ΈUnited States markusa

    I could replicate this issue. "Manage Display" can be broken if addtocalendar module is installed

    errors like
    Drupal\Core\Field\FieldException: Attempt to create a base field bundle override of field birth_date without a bundle in Drupal\Core\Field\Entity\BaseFieldOverride->__construct() (line 110 of /var/www/web/distro10.skvare.com/web/core/lib/Drupal/Core/Field/Entity/BaseFieldOverride.php).

    Backtrace:

    Backtrace	
    #0 /var/www/web/distro10.skvare.com/web/core/lib/Drupal/Core/Config/Entity/ConfigEntityStorage.php(222): Drupal\Core\Field\Entity\BaseFieldOverride->__construct()
    #1 /var/www/web/distro10.skvare.com/web/core/lib/Drupal/Core/Entity/EntityStorageBase.php(232): Drupal\Core\Config\Entity\ConfigEntityStorage->doCreate()
    #2 /var/www/web/distro10.skvare.com/web/core/lib/Drupal/Core/Field/Entity/BaseFieldOverride.php(75): Drupal\Core\Entity\EntityStorageBase->create()
    #3 /var/www/web/distro10.skvare.com/web/core/lib/Drupal/Core/Field/BaseFieldDefinition.php(784): Drupal\Core\Field\Entity\BaseFieldOverride::createFromBaseFieldDefinition()
    #4 /var/www/web/distro10.skvare.com/web/modules/contrib/addtocalendar/includes/addtocalendar.form.inc(91): Drupal\Core\Field\BaseFieldDefinition->getConfig()
    #5 /var/www/web/distro10.skvare.com/web/modules/contrib/addtocalendar/addtocalendar.module(34): _addtocalendar_build_form()
    #6 /var/www/web/distro10.skvare.com/web/core/modules/field_ui/src/Form/EntityViewDisplayEditForm.php(162): addtocalendar_field_formatter_third_party_settings_form()
    #7 /var/www/web/distro10.skvare.com/web/core/lib/Drupal/Core/Extension/ModuleHandler.php(388): Drupal\field_ui\Form\EntityViewDisplayEditForm->Drupal\field_ui\Form\{closure}()
    #8 /var/www/web/distro10.skvare.com/web/modules/contrib/config_track/src/Extension/ModuleHandler.php(236): Drupal\Core\Extension\ModuleHandler->invokeAllWith()
    #9 /var/www/web/distro10.skvare.com/web/core/modules/field_ui/src/Form/EntityViewDisplayEditForm.php(168): Drupal\config_track\Extension\ModuleHandler->invokeAllWith()
    #10 /var/www/web/distro10.skvare.com/web/core/modules/field_ui/src/Form/EntityDisplayFormBase.php(451): Drupal\field_ui\Form\EntityViewDisplayEditForm->thirdPartySettingsForm()
    #11 /var/www/web/distro10.skvare.com/web/core/modules/field_ui/src/Form/EntityViewDisplayEditForm.php(41): Drupal\field_ui\Form\EntityDisplayFormBase->buildFieldRow()
    #12 /var/www/web/distro10.skvare.com/web/core/modules/layout_builder/src/Form/LayoutBuilderEntityViewDisplayForm.php(227): Drupal\field_ui\Form\EntityViewDisplayEditForm->buildFieldRow()
    #13 /var/www/web/distro10.skvare.com/web/core/modules/field_ui/src/Form/EntityDisplayFormBase.php(213): Drupal\layout_builder\Form\LayoutBuilderEntityViewDisplayForm->buildFieldRow()
    #14 /var/www/web/distro10.skvare.com/web/core/modules/layout_builder/src/Form/LayoutBuilderEntityViewDisplayForm.php(47): Drupal\field_ui\Form\EntityDisplayFormBase->form()
    #15 /var/www/web/distro10.skvare.com/web/core/lib/Drupal/Core/Entity/EntityForm.php(107): Drupal\layout_builder\Form\LayoutBuilderEntityViewDisplayForm->form()

    I made a PR from the patch to run tests:
    https://github.com/eileenmcnaughton/civicrm_entity/pull/475

  • Status changed to Fixed 8 months ago
  • πŸ‡ΊπŸ‡ΈUnited States markusa

    PR Merged in github, going out in next release

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024