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
WP_CRON_HOOK
public
mixed
WP_CRON_HOOK
= 'action_scheduler_run_queue'
WP_CRON_SCHEDULE
public
mixed
WP_CRON_SCHEDULE
= 'every_minute'
Properties
$cleaner
protected
ActionScheduler_QueueCleaner
$cleaner
$monitor
protected
ActionScheduler_FatalErrorMonitor
$monitor
$store
protected
ActionScheduler_Store
$store
$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.
$runner
private
static ActionScheduler_QueueRunner
$runner
=
ull
Methods
__construct()
ActionScheduler_QueueRunner constructor.
public
__construct([ActionScheduler_Store $store = null ][, ActionScheduler_FatalErrorMonitor $monitor = null ][, ActionScheduler_QueueCleaner $cleaner = null ]) : mixed
Parameters
- $store : ActionScheduler_Store = null
- $monitor : ActionScheduler_FatalErrorMonitor = null
- $cleaner : ActionScheduler_QueueCleaner = null
Return values
mixed —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 —init()
public
init() : mixed
Tags
Return values
mixed —instance()
public
static instance() : ActionScheduler_QueueRunner
Tags
Return values
ActionScheduler_QueueRunner —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 —run()
Process actions in the queue.
public
run() : int
Return values
int —The number of actions processed.
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 —do_batch()
protected
do_batch([mixed $size = 100 ]) : mixed
Parameters
- $size : mixed = 100
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.
get_maximum_execution_time()
Get the maximum number of seconds a batch can run for.
protected
get_maximum_execution_time() : int
Tags
Return values
int —The number of seconds.
get_memory_limit()
Get memory limit
protected
get_memory_limit() : int
Based on WP_Background_Process::get_memory_limit()
Return values
int —get_time_limit()
Get the maximum number of seconds a batch can run for.
protected
get_time_limit() : 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 —run_cleanup()
Run the queue cleaner.
protected
run_cleanup() : mixed
Tags
Return values
mixed —schedule_next_instance()
Schedule the next instance of the action if necessary.
protected
schedule_next_instance(ActionScheduler_Action $action) : mixed
Parameters
- $action : ActionScheduler_Action
Return values
mixed —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