Fatal error with Drupal 11.1.x when adding fields

Created on 27 March 2025, 6 days ago

Problem/Motivation

With Shorthand 4.x and Drupal 11.1.x it is not possible to add fields to entities, an error is thrown:

TypeError: Cannot access offset of type Drupal\Core\StringTranslation\TranslatableMarkup in isset or empty in Drupal\Core\Plugin\DefaultPluginManager->doGetDefinition() (line 45 of core/lib/Drupal/Component/Plugin/Discovery/DiscoveryTrait.php).

This is because the LocalShorthandFieldType uses a categroy of '@Translation("Reference"),' - but translatable strings are no longer supported as categories.

Similar issues:
- https://www.drupal.org/project/entity_reference_display/issues/3486365 🐛 Using a translatable string as a category for field type is deprecated Active
- https://www.drupal.org/project/simple_oauth/issues/3480844 🐛 "Reference" must be defined in MODULE_NAME.field_type_categories.yml in assert() (line 183 of /var/www/html/web/core/lib/Drupal/Core/Field/FieldTypePluginManager.php) Needs review

Steps to reproduce

Install shorthand 4.x on DRupal 11.1.x, and try to add fields to a content type, or the user entity.

Proposed resolution

Use 'reference' instead of the translation for the category.

🐛 Bug report
Status

Needs review

Version

4.0

Component

Code

Created by

🇬🇧United Kingdom jkingsnorth

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