Drupal is a registered trademark of Dries Buytaert
Protected Pages 3.0.0 Major update available for module protected_pages (3.0.0). Commerce Core 3.3.8 Minor update available for module commerce (3.3.8). Search API HTML Element Filter 1.0.7 Minor update available for module search_api_html_element_filter (1.0.7). Layout Builder Reorder 2.0.1 Minor update available for module layout_builder_reorder (2.0.1). Ban 1.1.0 Minor update available for module ban (1.1.0). Field Formatter Range 2.0.0 Major update available for module field_formatter_range (2.0.0). Field Formatter Range 8.x-1.8 Minor update available for module field_formatter_range (8.x-1.8). UI Patterns (SDC in Drupal UI) 2.0.18 Minor update available for module ui_patterns (2.0.18). Search API Solr 4.3.11 Module search_api_solr updated after 14 months of inactivity (4.3.11). Provus Mega Menu Module provus_mega_menu crossed 1,000 active installs.

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.

Activity

Total releases
2
First release
Feb 2025
Latest release
4 months ago
Releases (12 mo)
1
Maintenance
Active

Releases

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