Problem/Motivation

Since #3594228: Remove explicit references to Layout Builder, a display declares no dependency on its sources, so core no longer deletes it with the field.
The sources stay, and rendering an entity of that bundle throws PluginNotFoundException.
#3562750: Field, Theme or module uninstalled only covers page layouts: its pruning needs onDependencyRemoval(), which only an entity class can implement.
Views displays have the same gap, see #3562750-21: Field, Theme or module uninstalled.

Steps to reproduce

  1. Build a display with Display Builder, with a source using a field.
  2. Delete the field.
  3. View an entity of that bundle: it fails.

Proposed resolution

Prune the sources from hooks with SourceTree::onDependencyRemoval(): hook_ENTITY_TYPE_predelete() for fields and hook_module_preuninstall() for modules.
Themes stay out: core has no hook before a theme uninstall, and the summary of #3562750: Field, Theme or module uninstalled accepts that fatal.

Remaining tasks

Check the hook order, then add tests.

User interface changes

None.

API changes

None.

Data model changes

None.

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

mogtofu33 created an issue. See original summary.

mogtofu33’s picture

Priority: Normal » Major
mogtofu33’s picture

pdureau’s picture

Assigned: Unassigned » pdureau

I will have a first look.

pdureau’s picture

Since #3594228: Remove explicit references to Layout Builder, a display declares no dependency on its sources, so core no longer deletes it with the field.
Indeed, this missing part was identified during the work:

EntityViewDisplayTrait nearly done, only remaining tasks: ConfigEntityInterface::calculateDependencies() and ConfigEntityInterface::onDependencyRemoval() may be addressable with #3540069: Evaluate ObjectWithPluginCollectionInterface

But forgotten from what we delivered.

We may already have similar issue with Views, let's check it too.

The #3540069: Evaluate ObjectWithPluginCollectionInterface may be interesting for Page Layout and Patterns because we "own" the entity logic, but for Entity View and Views, we don't own it and may need to rely on hooks.

pdureau’s picture

Status: Active » Needs work

Started

pdureau’s picture

Rebase caused a playwright fail. On it.