Fatal error when using unknown formatter

Created on 13 December 2024, 7 months ago

Problem/Motivation

When any of the components in a custom elements display has a formatter configured that cannot be found, a fatal error is thrown when building custom elements, and when visiting the UI to configure a CE display:

Drupal\Component\Plugin\Exception\PluginNotFoundException: The "..." plugin does not exist. Valid plugin IDs for Drupal\custom_elements\CustomElementsFieldFormatterPluginManager are: [all found ones]

Steps to reproduce

On a development site,

  • Visit custom elements display edit screen
  • In a code editor, go to any formatter class that is used here (e.g. AutoCeFieldFormatter)
  • Edit the id = "VALUE" to be a strange value; save
  • Clear cache
  • Reload custom elements display edit screen

What would Core do

There's no error.

When editing a display, it shows the first value in the dropdown.

When rendering a node, it also takes that 'first' value to render the node.

This is because the EntityViewDisplay::getRenderer() -> FormatterPluginManager::getInstance() call has a fallback for unknown plugins (whereas our EntityCeDisplay::getRenderer() -> FormatterPluginManager::createInstance() does not).

Proposed resolution

Keep thowing fatal error during build/render: API output should not change silently.

Fix the form: a user should be able to fix the fatal error through the UI.

🐛 Bug report
Status

Active

Version

3.0

Component

Code

Created by

🇳🇱Netherlands roderik Amsterdam,NL / Budapest,HU

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