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.
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
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()`.
Not all content is available!
It's likely this issue predates Contrib.social: some issue and comment data are missing.
No activities found.