Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 303482

Broken context-aware block plugins throw an unexpected exception

$
0
0

Problem/Motivation

"Assigned contexts were not satisfied" (error message) after deleting field used in layout

To replicate.

  1. Add a field to a content type, text field will do.
  2. Add a node of that type with a value in the added field.
  3. Edit layout for said content type.
  4. Display the new field.
  5. Edit content type and delete field.
  6. Edit layout, error thrown: "Assigned contexts were not satisfied"
  7. Apply code change work around, see Proposed resolution below
  8. Now edit the layout.. the block will be marked as "this block is no longer available".
  9. Delete the block.
  10. Save the layout.
  11. Undo the workaround: Uncomment the code we commented out.

Proposed resolution

Workaround: edit core/lib/Drupal/Core/Plugin/Context/ContextHandler.php and comment out the line:
throw new ContextException('Assigned contexts were not satisfied: ' . implode(',', array_keys($mappings)));

Possible solution:
At the point of "Edit content type and delete field." of the replication steps:
* Check if the field is being used in layoutbuilder
* Give the user feedback as to which layout is using the field.
* Suggest to the user to remove the field from the layout and then come back and delete the field.
* Alternatively give the user feedback about the field in layout builder, and request confirmation to give the option to remove the field from the layout automatically.

Remaining tasks

TBC

User interface changes

n/a

API changes

n/a

Data model changes

n/a

Release notes snippet

TBC


Viewing all articles
Browse latest Browse all 303482

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>