Illegal offset type in ...\ConfigEntityStorage->loadOverrideFree() when translating

Created on 12 February 2025, about 2 months ago

Problem/Motivation

If I try to access the translation page of a entity type definition I get the following error:
TypeError: Illegal offset type in Drupal\Core\Config\Entity\ConfigEntityStorage->loadOverrideFree() (line 479 of core/lib/Drupal/Core/Config/Entity/ConfigEntityStorage.php).

If I grasp it correctly this happens because we defined our own parameter loader here:

          $route->setDefault('external_entity_type', $this->entityTypeManager
            ->getStorage('external_entity_type')
            ->load($entity_type_id));

But the config translation handling expects an entity_id to be given which it can load itself.

Steps to reproduce

  1. Configure multiligual site
  2. Enable "External Entities Drupal.org example"
  3. Go to /admin/structure/external-entity-types
  4. Select "Translate" in the dropdown of "Drupal.org module - JSONAPI"

Proposed resolution

Instead of loading the entity right away pass on the entity id but declare it's underlying type:

          $route->setOption('parameters', [
            'external_entity_type' => [
              'type' => 'entity:external_entity_type'
            ]
          ]);

This should allow the parameter resolvers to properly manage the parameter.

Remaining tasks

  1. Write code
  2. Review
  3. Merge

User interface changes

None

API changes

None

Data model changes

None

🐛 Bug report
Status

Active

Version

3.0

Component

Code

Created by

🇨🇭Switzerland das-peter

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