Skip to main content
Drupal is a registered trademark of Dries Buytaert
Release: OpenID Connect / OAuth client 3.0.0-alpha9 New alpha version released for module openid_connect (3.0.0-alpha9). Usage Milestone: Google Analytics Module google_analytics crossed 1,000 active installs. Release: Timelinr 1.0.1 Minor update available for module timelinr (1.0.1). Release: GraphQL Compose Codegen 1.1.2 Minor update available for module graphql_compose_codegen (1.1.2). Release: Mapy.com 1.1.3 Minor update available for module mapycom (1.1.3). Release: Ckeditor5 entity browser 3.0.3 Minor update available for module ckeditor5_entity_browser (3.0.3). Release: Ckeditor5 entity browser 3.0.1 Minor update available for module ckeditor5_entity_browser (3.0.1). Release: Ckeditor5 entity browser 3.0.2 Minor update available for module ckeditor5_entity_browser (3.0.2). Release: Teamleader Integration 4.0.2 Minor update available for module teamleader (4.0.2). Module Revived: Entityqueue Buttons 1.1.2 Module entityqueue_buttons updated after 8 months of inactivity (1.1.2).

Cached moderation state

922 sites Security covered Drupal 10–11
View on drupal.org

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.

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
2
Tracked since
Feb 2025
Latest release
5 months ago
Releases (12 mo)
1
Maintenance
Active

Releases

Version Type Core Release date
1.1.2 Stable 10–11 Mar 11, 2026
1.1.1 Stable 10–11 Feb 10, 2025