ActionScheduler_DBLogger::clear_deleted_action_logs_single_batchpublicWC 1.0

Delete the action logs batch for an action.

Method of the class: ActionScheduler_DBLogger{}

No Hooks.

Returns

null. Nothing (null).

Usage

$ActionScheduler_DBLogger = new ActionScheduler_DBLogger();
$ActionScheduler_DBLogger->clear_deleted_action_logs_single_batch( $action_id, $cutoff_log_id, $batch, $batch_size );
$action_id(int) (required)
Action id.
$cutoff_log_id(int) (required)
Cutoff log ID. Retain logs generated after the cleanup begins. A value of -1 indicates the start of the cleanup.
$batch(int) (required)
The batch index is used solely for troubleshooting. Reviewing action arguments provides a clear understanding of progressive deletion.
$batch_size(int) (required)
Batch size.

ActionScheduler_DBLogger::clear_deleted_action_logs_single_batch() code WC 11.0.0

public function clear_deleted_action_logs_single_batch( $action_id, $cutoff_log_id, $batch, $batch_size ) {
	global $wpdb;

	if ( -1 === $cutoff_log_id ) {
		$cutoff_log_id = 1 + (int) $wpdb->get_var( $wpdb->prepare( "SELECT MAX(log_id) FROM {$wpdb->actionscheduler_logs} WHERE action_id = %d", $action_id ) );
	}

	$deleted  = (int) $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->actionscheduler_logs} WHERE action_id = %d AND log_id < %d LIMIT %d", $action_id, $cutoff_log_id, $batch_size ) );
	$continue = $deleted === $batch_size;
	if ( $continue ) {
		// Schedule immediately, as this action will not be selected during the current run and will have lower than normal priority.
		as_schedule_single_action( time(), 'action_scheduler_clear_deleted_action_logs_hook', array( $action_id, $cutoff_log_id, ++$batch, $batch_size ), '', false, 20 );
	}
}