Document how to run on installation of another module

Created on 26 August 2025, 18 days ago

By submitting patches for review, you agree to the Developer Certificate of Origin. A copy of this agreement can be found in the project root, named CONTRIBUTING.txt.

Problem/Motivation

I am making the module Retroactive workflow state β†’ and am relying on Cached moderation state because that felt more accessible, for a contrib solution, than relying on a core patch.

Unfortunately the well-documented initialization instructions β†’ cannot work for a contrib module because, as has recently been documented ( πŸ’¬ Documentation suggestion - hook_post_update_NAME Active ), hook_post_update_NAME() hooks do not run after install.

Proposed resolution

Document how to initialize the cached moderation state field in hook_install().

If that is not possible or not recommended (perhaps it is not or Cached moderation state would self-initialize?), find or file an issue in Drupal core about needing a "*.post_install.php" because the current situation inadvertently favors custom code over contributed solutions.

Remaining tasks

User interface changes

API changes

Data model changes

πŸ“Œ Task
Status

Active

Version

1.2

Component

Documentation

Created by

πŸ‡ΊπŸ‡ΈUnited States mlncn Minneapolis, MN, USA

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

Comments & Activities

  • Issue created by @mlncn
  • πŸ‡ΊπŸ‡ΈUnited States mlncn Minneapolis, MN, USA

    I've only just started using it myself, but maybe Batch Plugin β†’ module would make it easier to do this work through the UI, with Drush, or on cron, which is i guess what i need, to initialize cron queue batches from an install hook.

  • πŸ‡ΊπŸ‡ΈUnited States clayfreeman Paragould, AR

    As far as I'm aware, it's either not possible or not advisable to run a batch process on module installation. If you have evidence to the contrary, I'd be happy to document a sample install hook.

Production build 0.71.5 2024