Integration with content moderation

Created on 8 December 2022, about 2 years ago
Updated 11 February 2025, 12 days ago

Problem/Motivation

When using revisionable entities, 2 issues can appear with moderation states as we have the concept of default / non default revision:

  • The newly created revision is based on the default one, which skips any non default revision
  • The difference (add / delete) is based on the default revision, not the latest one

Steps to reproduce

  • Drupal core latest stable (9.4.x at the time of writing)
  • Use the default Article content type
  • Use the default Tags vocabulary
  • Add a field_content on the Tags vocabulary
  • Configure CER to use tags / content fields (see below)
  • Enable content moderation with the default editorial workflow, apply it to the Article content type
  • Create a "Tag 1" taxonomy term in the Tags vocabulary
  • Ideally test on a multilingual setup so we cover this as well (make Article translatable, Tags as well)
  • Cases described above are reproducible with the source language only

  • Create a published "Article 1" with "Tag 1" set and "Revision 1" in the body
  • CER adds Article 1 reference to Tag 1 ✅
  • Delete in a Draft of Article 1 the reference to Tag 1
  • CER already deletes the reference to Article 1 on Tag 1 ⚠️ we could potentially wait for a default revision of the Article here?
  • A new published / default revision of Article 1 with the deletion of Tag 1 is created, with the same timestamp as the previous published and resets the body field as well ❌ not expected, as there is potential content loss from the draft if a content editor starts to edit, it might be hard to recover by reverting a revision
  • Create a published "Article 2", with "Tag 1" set
  • Delete Article 2 reference on Tag 1
  • A new Published revision of Article 2 is created with the deletion of Tag 1 ✅
  • Create a published "Article 3", with "Tag 1" set
  • Save a new draft of Article 3, still with Tag 1 set
  • Delete in Tag 1 the reference to Article 3
  • A new published / default revision of Article 1 with the deletion of Tag 1 is created ❌ same case as the first test

Proposed resolution

A simple one: when using revisionable entities, no need to specifically check with workflows/content moderation, always use the latest revision if the entity implements RevisionableInterface.

Possible follow-up (configurable?): if one of the entity is not in the default revision state, defer CER sync until it reaches the default state. This could be useful to not alter corresponding entities when not expected. Example: A draft product removes or adds references to a product category term or another product that is published, we might want to defer on these corresponding entities only when the draft product gets published.

Remaining tasks

  • Provide a patch
  • Test on non translatable content
  • Test on translatable content with entity reference not translatable
  • Test on translatable content with entity reference translatable

User interface changes

n/a

API changes

n/a

Data model changes

n/a

📌 Task
Status

Needs work

Version

5.0

Component

Code

Created by

🇨🇭Switzerland colorfield Lausanne

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024