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

  1. Install Drupal with the Standard profile or the Umami demo profile.
  2. Create an Article node, or edit an existing one, and make sure there is some text in the Body field.
  3. Visit Administration > Configuration > Content authoring (/admin/config/content/formats) and disable the text format used by the Body field.
  4. 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

benjifisher created an issue. See original summary.

benjifisher’s picture

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.

smustgrave’s picture

Status: Active » Closed (outdated)

https://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.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.