Problem/Motivation
"Assigned contexts were not satisfied" (error message) after deleting field used in layout
To replicate.
- Add a field to a content type, text field will do.
- Add a node of that type with a value in the added field.
- Edit layout for said content type.
- Display the new field.
- Edit content type and delete field.
- Edit layout, error thrown: "Assigned contexts were not satisfied"
- Apply code change work around, see Proposed resolution below
- Now edit the layout.. the block will be marked as "this block is no longer available".
- Delete the block.
- Save the layout.
- 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