Problem/Motivation

Steps to reproduce:

  1. Add an extra field for a node bundle in a module.
  2. Add the extra field block to layout builder for the node bundle display defaults layout or in an override on a node of that bundle
  3. Uninstall the module
  4. View the node
  5. Observe there is a ContextException error: "Assigned contexts were not satisfied"

It would be ideal to avoid the Exception and the broken plugin to display the missing plugin text instead.

Proposed resolution

Issue arises because in \Drupal\layout_builder\SectionComponent::getPluginId(), the context mapping that was original configured for the extra field block is being applied to the fallback "broken" block plugin, which has no context definitions.

Proposed solution is to check that the instantiated plugin isn't the fallback plugin before trying to apply the context mapping

Remaining tasks

Needs review and tests

User interface changes

N/A

API changes

N/A

Data model changes

N/A

Release notes snippet

N/A

Original report by [username]

N/A

Comments

godotislate created an issue. See original summary.

godotislate’s picture

Issue tags: +Needs tests
StatusFileSize
new842 bytes

Patch per proposed resolution. Needs tests.

godotislate’s picture

StatusFileSize
new1.14 KB
new1.16 KB
tim.plunkett’s picture

Status: Active » Closed (duplicate)

I believe this is a duplicate of #3091309: Broken context-aware block plugins throw an unexpected exception
Same sort of fix, but just that the broken block plugin should not be passing the instanceof ContextAwarePluginInterface check.

godotislate’s picture