ActionScheduler_QueueCleaner::delete_actions
Delete actions.
Method of the class: ActionScheduler_QueueCleaner{}
Hooks from the method
Returns
Array. Deleted action IDs.
Usage
// private - for code of main (parent) class only $result = $this->delete_actions( $actions_to_delete, $lifespan, $context );
- $actions_to_delete(int[]) (required)
- List of action IDs to delete.
- $lifespan(int)
- Minimum scheduled age in seconds of the actions being deleted.
Default:null - $context(string)
- Context of the delete request.
Default:'old'
ActionScheduler_QueueCleaner::delete_actions() ActionScheduler QueueCleaner::delete actions code WC 10.7.0
private function delete_actions( array $actions_to_delete, $lifespan = null, $context = 'old' ) {
$deleted_actions = array();
if ( is_null( $lifespan ) ) {
$lifespan = $this->month_in_seconds;
}
foreach ( $actions_to_delete as $action_id ) {
try {
$this->store->delete_action( $action_id );
$deleted_actions[] = $action_id;
} catch ( Exception $e ) {
/**
* Notify 3rd party code of exceptions when deleting a completed action older than the retention period
*
* This hook provides a way for 3rd party code to log or otherwise handle exceptions relating to their
* actions.
*
* @param int $action_id The scheduled actions ID in the data store
* @param Exception $e The exception thrown when attempting to delete the action from the data store
* @param int $lifespan The retention period, in seconds, for old actions
* @param int $count_of_actions_to_delete The number of old actions being deleted in this batch
* @since 2.0.0
*/
do_action( "action_scheduler_failed_{$context}_action_deletion", $action_id, $e, $lifespan, count( $actions_to_delete ) );
}
}
return $deleted_actions;
}