Filter uncanny-automator-pro

automator_pro_loop_checkpoint_interval

Filters the interval in seconds between saving checkpoints in the Automator Pro loop.

add_filter( 'automator_pro_loop_checkpoint_interval', $callback, 10, 1 );

Description

Allows modification of the interval for saving batch progress in Uncanny Automator Pro background loops. Control how often checkpoints are saved, reducing serialization overhead. By default, checkpoints are saved every 25 items.


Usage

add_filter( 'automator_pro_loop_checkpoint_interval', 'your_function_name', 10, 1 );

Return Value

The filtered value.


Examples

<?php
/**
 * Example of how to hook into automator_pro_loop_checkpoint_interval.
 *
 * This example increases the checkpoint interval to 50, meaning the progress will
 * be saved every 50 items processed, rather than every 25. This can be useful
 * for very large loops where saving progress too frequently might introduce overhead.
 *
 * @param int $interval The current checkpoint interval in items.
 * @return int The modified checkpoint interval.
 */
function my_automator_pro_custom_checkpoint_interval( $interval ) {
	// Increase the checkpoint interval to 50 items.
	$new_interval = 50;

	// You could also add logic here to dynamically determine the interval
	// based on certain conditions, for example:
	// if ( is_user_logged_in() && current_user_can( 'manage_options' ) ) {
	//     $new_interval = 100; // For administrators, save less frequently
	// }

	return $new_interval;
}
add_filter( 'automator_pro_loop_checkpoint_interval', 'my_automator_pro_custom_checkpoint_interval', 10, 1 );

Placement

This code should be placed in the functions.php file of your active theme, a custom plugin, or using a code snippets plugin.


Source Code

uncanny-automator-pro/src/core/loops/loop/background-process/entity-actions.php:324

0
				)
			)
		);

		// P1: Checkpoint interval — save batch progress every N items instead of every item.
		// At ~32ms/item, 25 items ≈ 800ms max re-work on crash. Reduces serialization by ~90%.
		$checkpoint_interval = (int) apply_filters( 'automator_pro_loop_checkpoint_interval', 25 );

		// P2: DB guard interval — check is_paused/is_cancelled every N items instead of every item.
		// Saves 2 DB queries per skipped item. Max ~800ms delay responding to pause/cancel.
		$guard_db_interval = (int) apply_filters( 'automator_pro_loop_guard_db_interval', 25 );

		do {
			$batch      = $this->get_batch();


Scroll to Top