Automattic\WooCommerce\Internal\Logging
OrderLogsCleanupHelper::cleanup
Run all cleanup tasks: dangling order meta and old log files.
Also the callback for the extended cleanup action.
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() OrderLogsCleanupHelper::cleanup code WC 11.0.1
public function cleanup(): void {
$max_age = $this->get_max_age_in_seconds();
if ( 0 === $max_age ) {
return;
}
$files_swept_in_bulk = LogHandlerFileV2::class === LoggingUtil::get_default_handler();
$more_files = $files_swept_in_bulk && $this->cleanup_old_log_files( $max_age );
$more_orders = $this->cleanup_dangling_orders( $max_age, $files_swept_in_bulk );
// Each run handles a single batch, so that it can't grow unbounded on a large
// backlog. Anything left over is picked up by a follow-up run a few minutes later.
if ( $more_files || $more_orders ) {
$this->schedule_extended_cleanup();
}
}