Skip to main content
drupalreleases

Use direct release data with your AI assistant.

Learn more

Cached moderation state

Security covered Under active development 1,746 sites

This module provides a workaround for Drupal's content moderation system by creating a cached field that stores an entity's moderation state. This allows the moderation state to be used in entity queries, which is not possible with the standard computed field.

Introduction

Drupal's content moderation module uses a computed field to allow developers to access an entity's current state, but this approach has a major shortcoming: computed fields can't be used in entity queries. This module aims to provide a workaround that facilitates interoperability between entity query conditions and an entity's state.

How it works

This module provides a custom field, cached_moderation_state, that copies an entity's moderation_state field value before the entity is saved. This field is automatically added to all moderated entity bundles when the module is first installed and any time a workflow is updated, but it must be initialized for each moderated entity before first use.

For a more detailed explanation of how this module works, click here.

Installation and setup

Please consult the installation guide for more detailed instructions. Generally, the following steps are required to start using this module:

  1. Make the module available for installation via Composer or direct download.
  2. Enable the module via Drupal's module installation interface, Drush, or a hook_post_update_NAME() implementation in a dependent module.
  3. Initialize the cached_moderation_state field on all moderated entities.

After initial setup, you can use the cached_moderation_state field in entity queries.

Planned obsolescence

This module's ultimate goal is to be obsoleted by a change to Drupal core that would allow an entity's moderation state to be accessed using entity queries. We encourage everyone to help fulfill this goal by contributing to the following issue: #3025164: Provide a way for fields with computed or custom storage to decide how to impact entity queries.

Drupal 10–11

Ask your assistant about Cached moderation state

Check compatibility with your Drupal and PHP version, maintenance and security coverage, from current release data. How it works

Depends on

Dependencies of the latest stable release

  • content_moderation Drupal core
  • field Drupal core

Required by

Tracked projects that depend on this one

No tracked projects depend on this one yet.

Activity

Tracked releases
5
Tracked since
Jan 2024
Latest release
7 months ago
Releases (12 mo)
1
Maintenance
Active

Release Timeline

Releases

Version Type Core PHP Release date
1.1.2 Stable 10–11 Mar 11, 2026
1.1.1 Stable 10–11 Feb 10, 2025
1.2.x-dev Dev 10–11 PHP 8.1 Jun 10, 2024
1.1.0 Stable 10–11 PHP 8.1 Jun 10, 2024
1.0.1 Stable 9–10 PHP 8.1 Jan 29, 2024