Fatal error when saving translation configuration with computed bundle fields from hook_entity_bundle_field_info()

Created on 30 September 2025, 21 days ago

Problem/Motivation

When computed fields are defined via `hook_entity_bundle_field_info()` (bundle-specific fields), they appear in the translation configuration UI at `/admin/config/regional/content-language`. Attempting to save
translation settings causes a fatal error:

`Call to a member function getFieldStorageDefinition() on null in Drupal\Core\Field\Entity\BaseFieldOverride->getFieldStorageDefinition()`

Computed bundle fields don't exist in base field definitions. When the translation form submit handler calls `$field->getConfig($bundle)`, it attempts to create a `BaseFieldOverride` which requires a base field
definition. Since bundle fields lack this, the process fails at `BaseFieldOverride::getBaseFieldDefinition()` line 197 when trying to access `$fields[$this->getName()]` where `$fields` only contains base fields.

Steps to reproduce

1. Define a computed field via hook_entity_bundle_field_info() for a specific bundle:
function mymodule_entity_bundle_field_info(EntityTypeInterface $entity_type, $bundle, array $base_field_definitions) {
$fields = [];
if ($entity_type->id() === 'node' && $bundle === 'article') {
$fields['my_computed'] = BaseFieldDefinition::create('timestamp')
->setComputed(TRUE)
->setClass(MyComputedFieldItemList::class)
->setTranslatable(TRUE);
}
return $fields;
}
2. Clear cache
3. Navigate to /admin/config/regional/content-language
4. Check the "Translatable" checkbox for the Article content type
5. Observe the computed bundle field appears in the field list
6. Attempt to save the form
7. Fatal error occurs

Proposed resolution

Prevent bundle fields from appearing in the translation configuration UI by checking if fields exist in base field definitions before displaying them in
`_content_translation_form_language_content_settings_form_alter()`.

🐛 Bug report
Status

RTBC

Version

11.0 🔥

Component

content_moderation.module

Created by

🇵🇱Poland alorenc Wolsztyn, 🇵🇱

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.

No activities found.

Production build 0.71.5 2024