Automattic\WooCommerce\Internal\ProductFeed\Integrations\POSCatalog
AsyncGenerator::reduce_chunk_size
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.
Method of the class: AsyncGenerator{}
No Hooks.
Returns
int. The new effective chunk size.
Usage
// private - for code of main (parent) class only $result = $this->reduce_chunk_size( $option_key ): int;
- $option_key(string) (required)
- The option key for the feed generation status.
AsyncGenerator::reduce_chunk_size() AsyncGenerator::reduce chunk size code WC 11.1.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;
}