WC_Admin_Reports::delete_legacy_reports_transients │ public static │ WC 10.6.0

Execute legacy reports transient deletion (sync or async depending on the context)

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

Хуков нет.

Возвращает

void. Ничего (null).

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

$result = WC_Admin_Reports::delete_legacy_reports_transients( $order_id, $defer ): void;
$order_id(int) (обязательный)
Order ID (unused, exists for compatibility between the hooks we are integrating with).
$defer(true|false)
Whether to defer the deletion or execute.
По умолчанию: true

Список изменений

С версии 10.6.0 Введена.

Код WC_Admin_Reports::delete_legacy_reports_transients() WC 11.3.0

public static function delete_legacy_reports_transients( int $order_id, bool $defer = true ): void {
	// Deferring is only making sense on sites without object cache enabled (if enabled, no SQLs being executed).
	if ( $defer && ! wp_using_ext_object_cache() ) {
		static $skip_consequent;

		// Schedule the deletion, cap the execution to single pending event at any given time.
		$schedule = ! $skip_consequent && ! ActionSchedulerUtil::has_scheduled_action( 'woocommerce_delete_legacy_report_transients', null, 'woocommerce' );
		if ( $schedule ) {
			as_schedule_single_action( time() + MINUTE_IN_SECONDS, 'woocommerce_delete_legacy_report_transients', array( $order_id, false ), 'woocommerce' );
		}
		$skip_consequent = true;

		return;
	}

	delete_transient( 'wc_admin_report' );
	foreach ( self::get_reports() as $report_group ) {
		foreach ( $report_group['reports'] as $report_key => $report ) {
			delete_transient( 'wc_report_' . $report_key );
		}
	}
}