Problem/Motivation
This issue is a follow-up to #3537624: Deleting filter formats may result in data loss.
If an instance of a formatted text field has an invalid format, then the field is not displayed when the node (or other entity) is viewed. This behavior should not change for security reasons. But it would be helpful to alert admin users (any user with edit permission for the entity) to the problem, so that they can fix it.
Steps to reproduce
- Install Drupal with the Standard profile or the Umami demo profile.
- Create an Article node, or edit an existing one, and make sure there is some text in the Body field.
- Visit Administration > Configuration > Content authoring (
/admin/config/content/formats) and disable the text format used by the Body field. - View the node. The Body field is not displayed.
For Step 3, #3537624: Deleting filter formats may result in data loss suggests a PHP snippet that can be used to delete a text format (not just disable it). It is probably also possible to delete a text format using the jsonapi module. For testing purposes, an alternative is to use a SQL query to set the format to something invalid: for example, UPDATE node__field_body SET field_body_format = 'foo' WHERE entity_id = 19;.
Proposed resolution
When viewing the entity, display a warning that some fields are not displayed because they have invalid text formats.
The warning could be in a status message or in place of the field that is not displayed.
The warning should be visible only to users with permission to edit the entity. Make sure that the warning is properly cached.
Remaining tasks
User interface changes
Users with permission to edit the entity will see a warning about invalid text formats.
Introduced terminology
None
API changes
None
Data model changes
None
Release notes snippet
N/A
Comments
Comment #2
benjifisherComment #4
smustgrave commentedhttps://www.drupal.org/project/drupal/issues/3537624#comment-16522011 seems it's been requested this gets folded into the main issue so closing this. Am giving credit as the summary was very well done.