Cron_Runner::ajax_continue_import()

Summary

When an ajax request to get the current import status comes in, run the next step in the process by triggering the scheduled cron job.


Description

Runs at priority 5, before the ajax response handler


Return

(void)


Source

File: src/BigCommerce/Import/Runner/Cron_Runner.php

	public function ajax_continue_import() {
		try {
			// in case there's already an event scheduled, remove it
			wp_unschedule_hook( self::CONTINUE_CRON );

			// Then fire the action that the cron would have fired on the schedule.
			do_action( self::CONTINUE_CRON );

			// This will have the side effect of scheduling the next run, so the
			// cron can continue to run if the user leaves the page and the Ajax
			// requests stop coming.
		} catch ( \Exception $e ) {
			$message = __( 'The server sent an unexpected response. We’ll keep trying, so dont’t worry. If the problem persists, try turning on error logging in the Diagnostics settings panel.', 'bigcommerce' );
			if ( WP_DEBUG && $e->getMessage() ) {
				$message .= ' ' . sprintf( __( 'Error message: %s', 'bigcommerce' ), $e->getMessage() );
			}
			wp_send_json_error( [
				'code'    => 'internal_server_error',
				'message' => $message,
			], 500 );
		}
	}


User Contributed Notes

You must log in before being able to contribute a note or feedback.