Automattic\WooCommerce\Internal\BatchProcessing

BatchProcessingController::dequeue_processorprivateWC 1.0

Dequeue a processor once it has no more items pending processing.

Method of the class: BatchProcessingController{}

No Hooks.

Returns

null. Nothing (null).

Usage

// private - for code of main (parent) class only
$result = $this->dequeue_processor( $processor_class_name ): void;
$processor_class_name(string) (required)
Full processor class name.

BatchProcessingController::dequeue_processor() code WC 11.0.1

private function dequeue_processor( string $processor_class_name ): void {
	// Always resolve membership authoritatively inside the lock (no unguarded fast-path read): this runs when a
	// batch finishes, not on a per-request hot path, so correctness is preferred over skipping the lock.
	$removed = false;
	$this->mutate_enqueued_processors(
		function ( array $pending_processes ) use ( $processor_class_name, &$removed ): array {
			if ( ! in_array( $processor_class_name, $pending_processes, true ) ) {
				return $pending_processes;
			}
			$removed = true;
			return array_values( array_diff( $this->sanitize_processor_list( $pending_processes ), array( $processor_class_name ) ) );
		}
	);

	if ( $removed ) {
		$this->clear_processor_state( $processor_class_name );
	}
}