Automattic\WooCommerce\Internal\PushNotifications\Services
NotificationRetryHandler::handle_retry
ActionScheduler callback for retry jobs.
Reconstructs the notification from the stored type and resource ID, then delegates to the processor with is_retry=true.
Method of the class: NotificationRetryHandler{}
No Hooks.
Returns
null. Nothing (null).
Usage
$NotificationRetryHandler = new NotificationRetryHandler(); $NotificationRetryHandler->handle_retry( $type, $resource_id, $attempt ): void;
- $type(string) (required)
- The notification type.
- $resource_id(int) (required)
- The resource ID.
- $attempt(int) (required)
- The current retry attempt number (1-based).
Changelog
| Since 10.8.0 | Introduced. |
NotificationRetryHandler::handle_retry() NotificationRetryHandler::handle retry code WC 10.9.4
public function handle_retry( string $type, int $resource_id, int $attempt ): void {
try {
$notification = Notification::from_array(
array(
'type' => $type,
'resource_id' => $resource_id,
)
);
} catch ( Exception $e ) {
wc_get_logger()->error(
sprintf( 'Retry failed: %s', $e->getMessage() ),
array( 'source' => PushNotifications::FEATURE_NAME )
);
return;
}
try {
wc_get_container()->get( NotificationProcessor::class )->process(
$notification,
true,
$attempt
);
} catch ( Exception $e ) {
wc_get_logger()->error(
sprintf( 'Retry failed: %s', $e->getMessage() ),
array( 'source' => PushNotifications::FEATURE_NAME )
);
$this->schedule( $notification, null, $attempt );
}
}