Add optional BatchOperations method calls to perform pre and post batch

Created on 16 April 2024, 8 months ago
Updated 12 June 2024, 6 months ago

Problem/Motivation

Sometimes before a batch operation begins, we might want to take some initial action to
examples:

  • Put the site in maintenance mode
  • turn off cron
  • bypass queueing of data pushes

Anything that was done could be placed in an optional method that would get called on first sandbox init, and undon on sandbox complete.

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

✨ Feature request
Status

Fixed

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States swirt Florida

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

Merge Requests

Comments & Activities

  • Issue created by @swirt
  • πŸ‡ΊπŸ‡ΈUnited States swirt Florida

    The ability to add the following methods to your custom Batch Operation class has been added.

    /**
       * Optional method that is called once BEFORE the run of the batch.
       *
       * This can be used to turn on maintenance mode, disable indexing, or
       * anything else that needs to be done before running the BatchOperation.
       *
       * @param array $sandbox
       *   The sandbox by reference. Used for keeping state in the batch.
       *
       * @return string
       *   A message that will be added to the BatchOpLog
       */
      public function preBatchMethod(&$sandbox): string;
    
      /**
       * Optional method that is called once AFTER the run of the batch.
       *
       * This can be used to undo anything that was done in preBatchMethod(). Like
       * turn off maintenance mode, re-enable indexing, or
       * anything else that needs to be done after running the BatchOperation.
       *
       * @param array $sandbox
       *   The sandbox by reference. Used for keeping state in the batch.
       *
       * @return string
       *   A message that will be added to the BatchOpLog
       */
      public function postBatchMethod(&$sandbox): string;
    
    • swirt β†’ committed d30f25c3 on 1.0.x
      Issue #3441371 by swirt: Add optional method calls to perform pre and...
  • Status changed to Fixed 6 months ago
  • πŸ‡ΊπŸ‡ΈUnited States swirt Florida
  • πŸ‡ΊπŸ‡ΈUnited States swirt Florida
  • Status changed to Fixed 6 months ago
  • πŸ‡ΊπŸ‡ΈUnited States swirt Florida

    This has been released with 1.0.1-beta8 β†’

Production build 0.71.5 2024