Automattic\WooCommerce\Internal\PushNotifications\Services
NotificationProcessor::handle_safety_net
ActionScheduler callback for the safety net job. This will be scheduled for 60 seconds in the future when a notification is added to the PendingNotificationStore. If the initial send succeeds, or fails and is able to schedule a retry, this action will be unscheduled. If the initial send does not occur, or fails and cannot schedule a retry (e.g. out of memory, retry scheduling error) then this safety net will run.
Метод класса: NotificationProcessor{}
Хуков нет.
Возвращает
void. Ничего (null).
Использование
$NotificationProcessor = new NotificationProcessor(); $NotificationProcessor->handle_safety_net( $type, $resource_id, $extra ): void;
- $type(строка) (обязательный)
- The notification type.
- $resource_id(int) (обязательный)
- The resource ID.
- $extra(массив)
- Optional subclass-specific extras (e.g. event_type, stock_quantity_at_trigger). Empty for notification types whose state is fully described by type + resource_id.
По умолчанию:array()
Список изменений
| С версии 10.7.0 | Введена. |
Код NotificationProcessor::handle_safety_net() NotificationProcessor::handle safety net WC 11.2.2
public function handle_safety_net( string $type, int $resource_id, array $extra = array() ): void {
try {
// Use the `+` array union operator (not array_merge) so the positional
// $type and $resource_id always win over any colliding keys in $extra.
// Defends against a malformed payload reconstructing the wrong target.
$data = array(
'type' => $type,
'resource_id' => $resource_id,
) + $extra;
$notification = Notification::from_array( $data );
} catch ( Exception $e ) {
wc_get_logger()->error(
sprintf( 'Safety net failed: %s', $e->getMessage() ),
array( 'source' => PushNotifications::FEATURE_NAME )
);
return;
}
try {
$this->process( $notification, true );
} catch ( Exception $e ) {
wc_get_logger()->error(
sprintf( 'Safety net failed: %s', $e->getMessage() ),
array( 'source' => PushNotifications::FEATURE_NAME )
);
$this->retry_handler->schedule( $notification, null, 0 );
}
}