ActionScheduler_DBStore::make_action_from_db_recordprotectedWC 1.0

Create an action from a database record.

Method of the class: ActionScheduler_DBStore{}

No Hooks.

Returns

ActionScheduler_Action|ActionScheduler_CanceledAction|ActionScheduler_FinishedAction.

Usage

// protected - for code of main (parent) or child class
$result = $this->make_action_from_db_record( $data );
$data(object) (required)
Action database record.

ActionScheduler_DBStore::make_action_from_db_record() code WC 11.0.0

protected function make_action_from_db_record( $data ) {
	$args = json_decode( $data->args, true );
	if ( ! is_array( $args ) && $data->status === self::STATUS_CANCELED ) {
		// The handled corrupted action should appear in UI.
		$args = array();
	} else {
		$this->validate_args( $args, $data->action_id );
	}

	$schedule = @unserialize( $data->schedule ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.serialize_unserialize WordPress.PHP.NoSilencingOperator
	if ( false === $schedule && $data->status === self::STATUS_CANCELED ) {
		// The handled corrupted action should appear in UI.
		$schedule = new ActionScheduler_NullSchedule();
	} else {
		$this->validate_schedule( $schedule, $data->action_id );
	}

	$group = $data->group ? $data->group : '';

	return ActionScheduler::factory()->get_stored_action( $data->status, $data->hook, $args, $schedule, $group, $data->priority );
}