Automattic\WooCommerce\Internal\ProductFeed\Integrations\POSCatalog

AsyncGenerator::reduce_chunk_size │ private │ WC 1.0

Steps the effective chunk size down to the next-smaller configured size and persists it.

Called when a job gets stuck. Once at the smallest configured size it stays there.

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

Хуков нет.

Возвращает

int. The new effective chunk size.

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

// private - только в коде основоного (родительского) класса
$result = $this->reduce_chunk_size( $option_key ): int;
$option_key(строка) (обязательный)
The option key for the feed generation status.

Код AsyncGenerator::reduce_chunk_size() WC 11.2.2

private function reduce_chunk_size( string $option_key ): int {
	$current = $this->get_effective_chunk_size( $option_key );

	// CHUNK_SIZE_STEPS is descending, so the first step smaller than the current size is the next rung down.
	$next = $current;
	foreach ( self::CHUNK_SIZE_STEPS as $step ) {
		if ( $step < $current ) {
			$next = $step;
			break;
		}
	}

	update_option( $this->get_chunk_size_option_key( $option_key ), $next );

	wc_get_logger()->warning(
		'Product feed generation got stuck; reducing the chunk size for future runs.',
		array(
			'option_key'          => $option_key,
			'previous_chunk_size' => $current,
			'chunk_size'          => $next,
		)
	);

	return $next;
}