\ActionScheduler_QueueCleaner

Class ActionScheduler_QueueCleaner

Summary

Methods
Properties
Constants
__construct()
delete_old_actions()
clean_actions()
reset_timeouts()
mark_failures()
clean()
No public properties found
No constants found
get_batch_size()
$batch_size
N/A
delete_actions()
$store
$month_in_seconds
$default_statuses_to_purge
N/A

Properties

$batch_size

$batch_size : int

The batch size.

Type

normal

$store

$store : \ActionScheduler_Store

ActionScheduler_Store instance.

Type

normal

$month_in_seconds

$month_in_seconds : int

31 days in seconds.

Type

normal

$default_statuses_to_purge

$default_statuses_to_purge : string[]

Default list of statuses purged by the cleaner process.

Type

normal

Methods

__construct()

__construct(\ActionScheduler_Store|null  $store = null, int  $batch_size = 20) : mixed

ActionScheduler_QueueCleaner constructor.

Parameters

\ActionScheduler_Store|null $store

The store instance.

int $batch_size

The batch size.

Returns

mixed

delete_old_actions()

delete_old_actions() : array

Default queue cleaner process used by queue runner.

Returns

array

clean_actions()

clean_actions(string[]  $statuses_to_purge, \DateTime  $cutoff_date, int|null  $batch_size = null, string  $context = 'old') : array

Delete selected actions limited by status and date.

Parameters

string[] $statuses_to_purge

List of action statuses to purge. Defaults to canceled, complete.

\DateTime $cutoff_date

Date limit for selecting actions. Defaults to 31 days ago.

int|null $batch_size

Maximum number of actions per status to delete. Defaults to 20.

string $context

Calling process context. Defaults to old.

Returns

array —

Actions deleted.

reset_timeouts()

reset_timeouts(int  $time_limit = 300) : mixed

Unclaim pending actions that have not been run within a given time limit.

When called by ActionScheduler_Abstract_QueueRunner::run_cleanup(), the time limit passed as a parameter is 10x the time limit used for queue processing.

Parameters

int $time_limit

The number of seconds to allow a queue to run before unclaiming its pending actions. Default 300 (5 minutes).

Returns

mixed

mark_failures()

mark_failures(int  $time_limit = 300) : mixed

Mark actions that have been running for more than a given time limit as failed, based on the assumption some uncatchable and unloggable fatal error occurred during processing.

When called by ActionScheduler_Abstract_QueueRunner::run_cleanup(), the time limit passed as a parameter is 10x the time limit used for queue processing.

Parameters

int $time_limit

The number of seconds to allow an action to run before it is considered to have failed. Default 300 (5 minutes).

Returns

mixed

clean()

clean(int  $time_limit = 300) : mixed

Do all of the cleaning actions.

Parameters

int $time_limit

The number of seconds to use as the timeout and failure period. Default 300 (5 minutes).

Returns

mixed

get_batch_size()

get_batch_size() : int

Get the batch size for cleaning the queue.

Returns

int

delete_actions()

delete_actions(int[]  $actions_to_delete, int  $lifespan = null, string  $context = 'old') : array

Delete actions.

Parameters

int[] $actions_to_delete

List of action IDs to delete.

int $lifespan

Minimum scheduled age in seconds of the actions being deleted.

string $context

Context of the delete request.

Returns

array —

Deleted action IDs.