Automattic\WooCommerce\Internal\Logging

OrderLogsCleanupHelper::cleanup_dangling_orders │ private │ WC 1.0

Clean up a batch of orders with dangling debug log meta.

Dangling orders have _debug_log_source meta but no _debug_log_source_pending_deletion.

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

Хуков нет.

Возвращает

bool. True if there may be more orders left to clean up.

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

// private - только в коде основоного (родительского) класса
$result = $this->cleanup_dangling_orders( $max_age, $files_swept_in_bulk ): bool;
$max_age(int) (обязательный)
Maximum age in seconds before an order's debug log meta is eligible for cleanup.
$files_swept_in_bulk(true|false) (обязательный)
True if the file sweep is already deleting these orders' log files.

Код OrderLogsCleanupHelper::cleanup_dangling_orders() WC 11.2.2

private function cleanup_dangling_orders( int $max_age, bool $files_swept_in_bulk ): bool {
	$dangling_orders = $this->get_dangling_orders( $max_age );

	if ( empty( $dangling_orders ) ) {
		return false;
	}

	// Clearing each order's log source individually scans the log directory once per
	// order, so it's only worth doing when the bulk sweep isn't deleting the files.
	$deleted = $files_swept_in_bulk
		? $this->delete_debug_log_meta_entries( array_keys( $dangling_orders ) )
		: $this->clear_logs_and_delete_meta_entries( $dangling_orders );

	return $deleted && self::MAX_ORDERS_PER_RUN === count( $dangling_orders );
}