More disappearing captions when using content moderation

Created on 9 April 2025, about 1 month ago

Problem/Motivation

I'm still seeing a disappearing-captions case that doesn't appear to be fixed by #3184748. It's happening with nodes that have a draft/needs review/published workflow using core content moderation.

I'm also seeing an issue with captions disappearing from the form when a node is opened for editing. A cache rebuild seems to bring them back, but that option isn't going to be available to all content authors. I've worked around it for now with some custom code that loads the caption from the database when it is missing from the form.

Steps to reproduce

1. On a site using core content moderation, publish an entity with images and captions.
2. Open the node and save it as a draft. This creates a new revision, visible on the "latest version" tab.
3. The new revision has its captions. But the previous revision, which is still published, does not. That caption was deleted at lines 227-229 of image_field_caption.module.

      // Delete the caption associated to this field.
      $imageCaption->deleteCaption($entity->getEntityTypeId(), $entity->bundle(), $field_name, $entity->id(), $entity->language()
        ->getId());

Proposed resolution

One partial solution I found, not optimal, was to delete the above line ($imageCaption->deleteCaption) and add the revision id to the primary index of the image_field_caption table. One obvious side effect is that the table bloats with outdated captions. And even that solution seems to work only for the first workflow transition, not subsequent ones, as far as I can see.

Remaining tasks

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

Active

Version

2.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States rclemings

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024