Automattic\WooCommerce\Internal\TransientFiles

TransientFilesEngine::handle_expired_files_cleanup_action()publicWC 1.0

Run the expired files cleanup action and schedule a new one.

If files are actually deleted then we assume that more files are pending deletion and schedule the next action to run immediately. Otherwise (nothing was deleted) we schedule the next action for one day later (but this can be changed via the woocommerce_delete_expired_transient_files_interval

If the actual deletion process fails the next action is scheduled anyway for one day later or for the interval given by the filter.

NOTE: If the default interval is changed to something different from DAY_IN_SECONDS, please adjust the "every 24h" text in add_debug_tools_entries too.

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

Возвращает

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

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

$TransientFilesEngine = new TransientFilesEngine();
$TransientFilesEngine->handle_expired_files_cleanup_action(): void;

Код TransientFilesEngine::handle_expired_files_cleanup_action() WC 9.6.1

public function handle_expired_files_cleanup_action(): void {
	$new_interval = null;

	try {
		$result = $this->delete_expired_files();
		if ( $result['deleted_count'] > 0 ) {
			$new_interval = 1;
		}
	} finally {
		if ( is_null( $new_interval ) ) {

			/**
			 * Filter to alter the interval between the actions that delete expired transient files.
			 *
			 * @param int $interval The default time before the next action run, in seconds.
			 * @return int The time to actually wait before the next action run, in seconds.
			 *
			 * @since 8.5.0
			 */
			$new_interval = apply_filters( 'woocommerce_delete_expired_transient_files_interval', DAY_IN_SECONDS );
		}

		$next_time = $this->legacy_proxy->call_function( 'time' ) + $new_interval;
		$this->legacy_proxy->call_function( 'as_schedule_single_action', $next_time, self::CLEANUP_ACTION_NAME, array(), self::CLEANUP_ACTION_GROUP );
	}
}