Automattic\WooCommerce\Internal\PushNotifications\Services

PendingNotificationStore::schedule_safety_net │ private │ WC 10.7.0

Schedules an ActionScheduler safety net job for the notification.

If the shutdown hook never fires (OOM, SIGKILL, etc.), this job guarantees the notification is still processed.

Method of the class: PendingNotificationStore{}

No Hooks.

Returns

void. Nothing (null).

Usage

// private - for code of main (parent) class only
$result = $this->schedule_safety_net( $notification ): void;
$notification(Notification) (required)
The notification to schedule.

Changelog

Since 10.7.0 Introduced.

PendingNotificationStore::schedule_safety_net() code WC 11.1.2

private function schedule_safety_net( Notification $notification ): void {
	// Canonical, identity-keyed args shared with NotificationProcessor::cancel_safety_net().
	// Action Scheduler matches stored args by exact equality, so both sides must derive
	// them from the same place; see Notification::get_safety_net_args().
	$args = $notification->get_safety_net_args();

	if ( as_has_scheduled_action( NotificationProcessor::SAFETY_NET_HOOK, $args, NotificationProcessor::ACTION_SCHEDULER_GROUP ) ) {
		return;
	}

	as_schedule_single_action(
		time() + NotificationProcessor::SAFETY_NET_DELAY,
		NotificationProcessor::SAFETY_NET_HOOK,
		$args,
		NotificationProcessor::ACTION_SCHEDULER_GROUP,
		true
	);
}