General usage information

Last updated on
30 August 2022

Usage in entity queries

The cached_moderation_state field behaves as a direct replacement for the moderation_state field when used in an entity query:

// This example queries the default revision for an entity type.
$node_ids = \Drupal::entityQuery('node')
  ->condition('cached_moderation_state', 'published')
  ->accessCheck(FALSE)
  ->execute();
// This example queries all revisions for an entity type.
$node_ids = \Drupal::entityQuery('node')
  ->condition('cached_moderation_state', ['draft', 'in_review'], 'IN')
  ->accessCheck(TRUE)
  ->allRevisions()
  ->execute();

Usage on a loaded entity

The maintainers of this project discourage any use of the cached_moderation_state field on entity objects. Developers should use the computed moderation_state field provided by the content moderation module instead.

Drush commands

Several commands are provided by this module:

  • cached-moderation-state:list-moderated-bundles [--format=FORMAT]
  • cached-moderation-state:sync-fields
  • cached-moderation-state:update [--batch-size=N] [--only-uninitialized]
  • cached-moderation-state:update-all [--batch-size=N] [--only-uninitialized]

Detailed usage information can be retrieved for each command as follows:

drush cached-moderation-state:update-all --help

Help improve this page

Page status: No known problems

You can: