Automattic\WooCommerce\Internal\BatchProcessing
BatchProcessingController::update_processor_state
Update the state for a processor after a batch has completed processing.
Метод класса: BatchProcessingController{}
Хуков нет.
Возвращает
null. Ничего (null).
Использование
// private - только в коде основоного (родительского) класса $result = $this->update_processor_state( $batch_processor, $time_taken, ?\Exception $last_error ): void;
- $batch_processor(BatchProcessorInterface) (обязательный)
- Batch processor instance.
- $time_taken(float) (обязательный)
- Time take by the batch to complete processing.
- ?\Exception $last_error
- .
По умолчанию:null
Код BatchProcessingController::update_processor_state() BatchProcessingController::update processor state WC 10.9.4
private function update_processor_state( BatchProcessorInterface $batch_processor, float $time_taken, ?\Exception $last_error = null ): void {
$current_status = $this->get_process_details( $batch_processor );
$current_status['total_time_spent'] += $time_taken;
$current_status['last_error'] = null !== $last_error ? $last_error->getMessage() : null;
if ( null !== $last_error ) {
$current_status['recent_failures'] = ( $current_status['recent_failures'] ?? 0 ) + 1;
$current_status['batch_last_failure'] = current_time( 'mysql' );
if ( is_null( $current_status['batch_first_failure'] ) ) {
$current_status['batch_first_failure'] = $current_status['batch_last_failure'];
}
} else {
$current_status['recent_failures'] = 0;
$current_status['batch_first_failure'] = null;
$current_status['batch_last_failure'] = null;
}
update_option( $this->get_processor_state_option_name( $batch_processor ), $current_status, false );
}