Automattic\WooCommerce\Internal\BatchProcessing
BatchProcessingController::enqueue_processor
Enqueue a processor so that it will get batch processing requests from within scheduled actions.
Method of the class: BatchProcessingController{}
No Hooks.
Returns
null. Nothing (null).
Usage
$BatchProcessingController = new BatchProcessingController(); $BatchProcessingController->enqueue_processor( $processor_class_name ): void;
- $processor_class_name(string) (required)
- Fully qualified class name of the processor, must implement
BatchProcessorInterface.
BatchProcessingController::enqueue_processor() BatchProcessingController::enqueue processor code WC 11.0.1
public function enqueue_processor( string $processor_class_name ): void {
/*
* Fast path: if the processor is already enqueued and the stored list is clean, there is nothing to write.
* This avoids taking the lock and re-reading the option on the hot path, which matters because
* DataSynchronizer::handle_continuous_background_sync() calls this on the 'shutdown' hook of every request
* when HPOS background sync runs in continuous mode. The check uses the (possibly request-cached) value;
* the authoritative re-read happens inside the critical section below only when an update is actually needed.
*/
if ( $this->enqueued_list_needs_update( $this->get_enqueued_processors(), $processor_class_name ) ) {
$this->mutate_enqueued_processors(
function ( array $pending_updates ) use ( $processor_class_name ): array {
$deduplicated_updates = $this->sanitize_processor_list( $pending_updates );
if ( ! in_array( $processor_class_name, $deduplicated_updates, true ) ) {
$deduplicated_updates[] = $processor_class_name;
}
return $deduplicated_updates;
}
);
}
$this->schedule_watchdog_action( false, true );
}