Automattic\WooCommerce\Internal\ProductFeed\Integrations\POSCatalog

AsyncGenerator::discard_feedprivateWC 1.0

Deletes the feed file referenced by a status, if any.

Completed feeds expose a full path; in-progress chunked feeds only track a file name.

Method of the class: AsyncGenerator{}

No Hooks.

Returns

null. Nothing (null).

Usage

// private - for code of main (parent) class only
$result = $this->discard_feed( $status ): void;
$status(array) (required)
The feed generation status.

AsyncGenerator::discard_feed() code WC 11.0.0

private function discard_feed( array $status ): void {
	// A completed feed exposes a full path; an in-progress chunked feed only tracks a file name.
	// Reduce either to a plain identifier and let ResumableFeedInterface::delete() validate it and confine
	// the deletion to the feed directory, so a tampered path read back from the option can never escape it.
	$identifier = ! empty( $status['file_name'] )
		? (string) $status['file_name']
		: ( ! empty( $status['path'] ) ? wp_basename( (string) $status['path'] ) : '' );

	if ( '' !== $identifier ) {
		$this->integration->create_feed()->delete( $identifier );
	}
}