Issue with Content Moderation states

Created on 6 August 2025, 10 days ago

I LOVE this module. Thank you for creating it!

Problem/Motivation

I need to use the content moderation states for my status field and kanban columns.

This is essentially working for me, but not in the way I need it to work. I'm not sure if this is a personal edge case, vs the way it should work.

It works great and supports my workflow for newly created content. I have the following moderation states configured: assigned, in progress, ready for review, and published.

The problem is I want to use the same workflow and kanban board for existing published content. For example, the University's Alumni landing page (which has been published for years) needs significant revisions. Since the node is governed by content moderation, someone can create a draft (either assigned, in progress or ready for review), and work can be done on it while the pubic continues to see the old published version. But when we do this, it ends up in the Published column of the kanban board. This is correct in the sense that the latest published revision of the node is in the Published state. But for our purposes, I want the kanban board status to reflect the status of the lates revision whether published or not.

Steps to reproduce

  1. Install and install this module
  2. Add status and other required fields to at least one content type
  3. Enable content moderation
  4. Configure a content moderation workflow (for the above content type) with several states and the needed transitions
  5. Configure a kanban view, setting the status field to the content_moderation field
  6. Create a Published node
  7. Edit the node and create a draft
  8. Desired results: node appears in the draft column

Proposed resolution

I have a patch I have written that delivers the desired functionality.

Remaining tasks

This could break the other methods this module provides for status (field_states and taxonomy terms). I haven't had a chance to validate that yet, but it seems to work well for our purposes on our D11.2 site.

User interface changes

None

✨ Feature request
Status

Active

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States banoodle San Francisco, CA

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

Comments & Activities

  • Issue created by @banoodle
  • πŸ‡ΊπŸ‡ΈUnited States banoodle San Francisco, CA

    Uploading a patch that works on current 1.0.x-dev release (and core 11.2).

  • πŸ‡ΊπŸ‡ΈUnited States banoodle San Francisco, CA
  • πŸ‡«πŸ‡·France lazzyvn paris

    You can try module field states transition it is 2 times better than content moderate state and kanban is full support module field states transitions

  • πŸ‡«πŸ‡·France lazzyvn paris

    Your patch cannot be merged in dev because it does not respect drupal phpstan and phpcs standards

  • πŸ‡ΊπŸ‡ΈUnited States banoodle San Francisco, CA

    Attaching new version of patch that fixes my coding standard issues.

  • πŸ‡«πŸ‡·France lazzyvn paris

    this patch is not good at all
    If an entity is not a node then it has to run a foreach all rows this is not optimal

    
      $ids = [];
    
      foreach ($rows as $key => $row) {
        $revision = $row->_entity;
        // Get the *node ID* from the revision entity.
        if ($revision->hasField('nid')) {
          $nid = $revision->get('nid')->value;
          $ids[$key] = $nid;
        }
      }
      // Get unique model values and their original keys.
      $unique_ids = array_unique($ids);
      // Use array_intersect_key to filter the original $rows array
      // based on the keys of the unique ids values.
      $unique_rows = array_intersect_key($rows, $unique_ids);
      $rows = $unique_rows;
    

    another code can't pass phpstan exemple
    you need to use injection dependency. but why does it always have to be node? there are many other entities like user, taxonomy or custom entities ECK?

    
        $entity_type_manager = \Drupal::entityTypeManager();
        $revision_ids = \Drupal::entityQuery('node')
    ....
    
Production build 0.71.5 2024