Documentation

ActionScheduler_QueueRunner extends ActionScheduler_Abstract_QueueRunner
in package

Class ActionScheduler_QueueRunner

Table of Contents

WP_CRON_HOOK  = 'action_scheduler_run_queue'
WP_CRON_SCHEDULE  = 'every_minute'
$cleaner  : ActionScheduler_QueueCleaner
$monitor  : ActionScheduler_FatalErrorMonitor
$store  : ActionScheduler_Store
$created_time  : int
The created time.
$runner  : ActionScheduler_QueueRunner
__construct()  : mixed
ActionScheduler_QueueRunner constructor.
add_wp_cron_schedule()  : mixed
get_allowed_concurrent_batches()  : int
Get the number of concurrent batches a runner allows.
init()  : mixed
instance()  : ActionScheduler_QueueRunner
process_action()  : mixed
Process an individual action.
run()  : int
Process actions in the queue.
batch_limits_exceeded()  : bool
See if the batch limits have been exceeded, which is when memory usage is almost at the maximum limit, or the time to process more actions will exceed the max time limit.
clear_caches()  : mixed
Running large batches can eat up memory, as WP adds data to its object cache.
do_batch()  : mixed
get_execution_time()  : int
Get the number of seconds the process has been running.
get_maximum_execution_time()  : int
Get the maximum number of seconds a batch can run for.
get_memory_limit()  : int
Get memory limit
get_time_limit()  : int
Get the maximum number of seconds a batch can run for.
memory_exceeded()  : bool
Memory exceeded
run_cleanup()  : mixed
Run the queue cleaner.
schedule_next_instance()  : mixed
Schedule the next instance of the action if necessary.
time_likely_to_be_exceeded()  : bool
Check if the host's max execution time is (likely) to be exceeded if processing more actions.

Constants

Properties

$created_time

The created time.

private int $created_time

Represents when the queue runner was constructed and used when calculating how long a PHP request has been running. For this reason it should be as close as possible to the PHP request start time.

Methods

add_wp_cron_schedule()

public add_wp_cron_schedule(mixed $schedules) : mixed
Parameters
$schedules : mixed
Return values
mixed

get_allowed_concurrent_batches()

Get the number of concurrent batches a runner allows.

public get_allowed_concurrent_batches() : int
Return values
int

process_action()

Process an individual action.

public process_action(int $action_id) : mixed
Parameters
$action_id : int

The action ID to process.

Return values
mixed

batch_limits_exceeded()

See if the batch limits have been exceeded, which is when memory usage is almost at the maximum limit, or the time to process more actions will exceed the max time limit.

protected batch_limits_exceeded(int $processed_actions) : bool

Based on WC_Background_Process::batch_limits_exceeded()

Parameters
$processed_actions : int

The number of actions processed so far - used to determine the likelihood of exceeding the time limit if processing another action

Return values
bool

clear_caches()

Running large batches can eat up memory, as WP adds data to its object cache.

protected clear_caches() : mixed

If using a persistent object store, this has the side effect of flushing that as well, so this is disabled by default. To enable:

add_filter( 'action_scheduler_queue_runner_flush_cache', '__return_true' );

Return values
mixed

get_execution_time()

Get the number of seconds the process has been running.

protected get_execution_time() : int
Return values
int

The number of seconds.

memory_exceeded()

Memory exceeded

protected memory_exceeded() : bool

Ensures the batch process never exceeds 90% of the maximum WordPress memory.

Based on WP_Background_Process::memory_exceeded()

Return values
bool

time_likely_to_be_exceeded()

Check if the host's max execution time is (likely) to be exceeded if processing more actions.

protected time_likely_to_be_exceeded(int $processed_actions) : bool
Parameters
$processed_actions : int

The number of actions processed so far - used to determine the likelihood of exceeding the time limit if processing another action

Return values
bool

Search results