Generated with the help of an LLM.

Claude Code helped trace the cause, write the unit test and draft this summary. I reproduced the bug, reviewed the change and the test, and edited the text.

Problem/Motivation

EntityResolverManager::getEntityTypes() keeps its own copy of the entity type definitions and never resets it. When entity types are added later in the same process, routes for them get no parameters option. The entity is then not upcast, _entity_access gets a plain ID and the page returns 403 until the next cache rebuild.

Core itself is not affected: installing a module rebuilds the container, and with it this service. Modules that create entity types at runtime are, for example ECK when a config import creates several entity types.

The copy came with #1906810: Require type hints for automatic entity upcasting. Before, EntityRouteAlterSubscriber read the definitions on every router rebuild.

Steps to reproduce

  1. Export config with two or more ECK entity types (ECK 2.1.0).
  2. Run drush site:install --existing-config.
  3. Without clearing caches, visit the edit form of an entity of these types: 403 for a user with the "edit any" permission.
  4. Run drush cr: the same page works.

Proposed resolution

Remove the copy and call $this->entityTypeManager->getDefinitions() directly.
The entity type manager already caches the definitions in memory and resets them in clearCachedDefinitions(), so the copy saves nothing.

Remaining tasks

Review

User interface changes

None

Introduced terminology

None

API changes

None

Data model changes

None

Release notes snippet

None

Issue fork drupal-3638564

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

herved created an issue. See original summary.

herved’s picture

Issue summary: View changes

herved’s picture

Status: Active » Needs review
ioana apetri’s picture

Tested manually: with ECK entity types in the exported config, after drush site:install --existing-config the entity edit form returned 403 without a cr.
After applying the MR the same page works.
+1 RTBC

Thank you!