Automattic\WooCommerce\Internal\BatchProcessing

BatchProcessingController::enqueue_processorpublicWC 1.0

Enqueue a processor so that it will get batch processing requests from within scheduled actions.

Метод класса: BatchProcessingController{}

Хуков нет.

Возвращает

null. Ничего (null).

Использование

$BatchProcessingController = new BatchProcessingController();
$BatchProcessingController->enqueue_processor( $processor_class_name ): void;
$processor_class_name(строка) (обязательный)
Fully qualified class name of the processor, must implement BatchProcessorInterface.

Код BatchProcessingController::enqueue_processor() WC 10.9.4

public function enqueue_processor( string $processor_class_name ): void {
	$pending_updates = $this->get_enqueued_processors();

	// De-duplicate defensively. Historically this method compared the class name against array_keys() rather
	// than the stored values, so the same processor was appended on every call and bloated the option. Building
	// the unique list in a single pass heals stores already carrying duplicates on their next enqueue while
	// keeping only one entry per class name in memory (so the cleanup stays bounded even when the stored list
	// ballooned to thousands of entries), and skips any non-string values a corrupted option may hold.
	$deduplicated_updates = array();
	$seen                 = array();
	foreach ( $pending_updates as $value ) {
		if ( is_string( $value ) && ! isset( $seen[ $value ] ) ) {
			$seen[ $value ]         = true;
			$deduplicated_updates[] = $value;
		}
	}
	if ( ! in_array( $processor_class_name, $deduplicated_updates, true ) ) {
		$deduplicated_updates[] = $processor_class_name;
	}
	if ( $deduplicated_updates !== $pending_updates ) {
		$this->set_enqueued_processors( $deduplicated_updates );
	}

	$this->schedule_watchdog_action( false, true );
}