ding_processes, true ) ) {
$pending_processes = array_diff( $pending_processes, array( $processor_class_name ) );
$this->set_enqueued_processors( $pending_processes );
}
}
/**
* Helper method to set the enqueued processor class names.
*
* @param array $processors List of full processor class names.
*/
private function set_enqueued_processors( array $processors ): void {
update_option( self::ENQUEUED_PROCESSORS_OPTION_NAME, $processors, false );
}
/**
* Check if a particular processor is enqueued.
*
* @param string $processor_class_name Fully qualified class name of the processor.
*
* @return bool True if the processor is enqueued.
*/
public function is_enqueued( string $processor_class_name ) : bool {
return in_array( $processor_class_name, $this->get_enqueued_processors(), true );
}
/**
* Dequeue and de-schedule a processor instance so that it won't be processed anymore.
*
* @param string $processor_class_name Fully qualified class name of the processor.
* @return bool True if the processor has been dequeued, false if the processor wasn't enqueued (so nothing has been done).
*/
public function remove_processor( string $processor_class_name ): bool {
$enqueued_processors = $this->get_enqueued_processors();
if ( ! in_array( $processor_class_name, $enqueued_processors, true ) ) {
return false;
}
$enqueued_processors = array_diff( $enqueued_processors, array( $processor_class_name ) );
if ( empty( $enqueued_processors ) ) {
$this->force_clear_all_processes();
} else {
update_option( self::ENQUEUED_PROCESSORS_OPTION_NAME, $enqueued_processors, false );
as_unschedule_all_actions( self::PROCESS_SINGLE_BATCH_ACTION_NAME, array( $processor_class_name ) );
}
return true;
}
/**
* Dequeues and de-schedules all the processors.
*/
public function force_clear_all_processes(): void {
as_unschedule_all_actions( self::PROCESS_SINGLE_BATCH_ACTION_NAME );
as_unschedule_all_actions( self::WATCHDOG_ACTION_NAME );
update_option( self::ENQUEUED_PROCESSORS_OPTION_NAME, array(), false );
}
/**
* Log an error that happened while processing a batch.
*
* @param \Exception $error Exception object to log.
* @param BatchProcessorInterface $batch_processor Batch processor instance.
* @param array $batch Batch that was being processed.
*/
protected function log_error( \Exception $error, BatchProcessorInterface $batch_processor, array $batch ) : void {
$batch_detail_string = '';
// Log only first and last, as the entire batch may be too big.
if ( count( $batch ) > 0 ) {
$batch_detail_string = "\n" . wp_json_encode(
array(
'batch_start' => $batch[0],
'batch_end' => end( $batch ),
),
JSON_PRETTY_PRINT
);
}
$error_message = "Error processing batch for {$batch_processor->get_name()}: {$error->getMessage()}" . $batch_detail_string;
/**
* Filters the error message for a batch processing.
*
* @param string $error_message The error message that will be logged.
* @param \Exception $error The exception that was thrown by the processor.
* @param BatchProcessorInterface $batch_processor The processor that threw the exception.
* @param array $batch The batch that was being processed.
* @return string The actual error message that will be logged.
*
* @since 6.8.0
*/
$error_message = apply_filters( 'wc_batch_processing_log_message', $error_message, $error, $batch_processor, $batch );
$this->logger->error( $error_message, array( 'exception' => $error ) );
}
}
Fatal error: Uncaught Error: Class 'Automattic\WooCommerce\Internal\BatchProcessing\BatchProcessingController' not found in /home/arasetne/public_html/wp-content/plugins/woocommerce/src/Internal/DependencyManagement/ServiceProviders/BatchProcessingServiceProvider.php:35
Stack trace:
#0 /home/arasetne/public_html/wp-content/plugins/woocommerce/lib/packages/League/Container/ServiceProvider/ServiceProviderAggregate.php(102): Automattic\WooCommerce\Internal\DependencyManagement\ServiceProviders\BatchProcessingServiceProvider->register()
#1 /home/arasetne/public_html/wp-content/plugins/woocommerce/lib/packages/League/Container/Container.php(172): Automattic\WooCommerce\Vendor\League\Container\ServiceProvider\ServiceProviderAggregate->register('Automattic\\WooC...')
#2 /home/arasetne/public_html/wp-content/plugins/woocommerce/src/Internal/DependencyManagement/ExtendedContainer.php(158): Automattic\WooCommerce\Vendor\League\Container\Container->get('Automattic\\WooC...', false)
#3 /home/arasetne/public_html/wp-content/plugins/wo in /home/arasetne/public_html/wp-content/plugins/woocommerce/src/Internal/DependencyManagement/ServiceProviders/BatchProcessingServiceProvider.php on line 35
Fatal error: Uncaught Automattic\WooCommerce\Vendor\League\Container\Exception\ContainerException: Service provider lied about providing (Automattic\WooCommerce\Internal\BatchProcessing\BatchProcessingController) service in /home/arasetne/public_html/wp-content/plugins/woocommerce/lib/packages/League/Container/Container.php:175
Stack trace:
#0 /home/arasetne/public_html/wp-content/plugins/woocommerce/src/Internal/DependencyManagement/ExtendedContainer.php(158): Automattic\WooCommerce\Vendor\League\Container\Container->get('Automattic\\WooC...', false)
#1 /home/arasetne/public_html/wp-content/plugins/woocommerce/lib/packages/League/Container/Argument/ArgumentResolverTrait.php(45): Automattic\WooCommerce\Internal\DependencyManagement\ExtendedContainer->get('Automattic\\WooC...')
#2 [internal function]: Automattic\WooCommerce\Vendor\League\Container\Definition\Definition->Automattic\WooCommerce\Vendor\League\Container\Argument\{closure}('Automattic\\WooC...')
#3 /home/arasetne/public_html/wp-content/plugins/woocommerce/lib/p in /home/arasetne/public_html/wp-content/plugins/woocommerce/lib/packages/League/Container/Container.php on line 175