Automattic\WooCommerce\Internal\Logging

OrderLogsCleanupHelper::cleanuppublicWC 10.7.0

Run all cleanup tasks: dangling order meta and old log files.

Method of the class: OrderLogsCleanupHelper{}

No Hooks.

Returns

null. Nothing (null).

Usage

$OrderLogsCleanupHelper = new OrderLogsCleanupHelper();
$OrderLogsCleanupHelper->cleanup(): void;

Changelog

Since 10.7.0 Introduced.

OrderLogsCleanupHelper::cleanup() code WC 10.8.1

public function cleanup(): void {
	$max_age = $this->get_max_age_in_seconds();

	if ( 0 === $max_age ) {
		return;
	}

	// Dangling orders have `_debug_log_source` meta but no `_debug_log_source_pending_deletion`.
	$dangling_orders = $this->get_dangling_orders( $max_age );
	$this->clear_logs_and_delete_meta( $dangling_orders );

	// Old log files are those that are older than the given max age.
	$this->cleanup_old_log_files( $max_age );
}