WC_Tracker::record_send_failure
Record a failed delivery attempt.
The attempt was already counted before the snapshot was built, so this only decides whether to keep retrying: a non-retryable failure or the last allowed attempt gives up on the current snapshot. Retry state is discarded when tracking was turned off while the request was in flight.
Метод класса: WC_Tracker{}
Хуков нет.
Возвращает
null. Ничего (null).
Использование
$result = WC_Tracker::record_send_failure( $retryable, $status, $error_code, $body_bytes ): void;
- $retryable(true|false) (обязательный)
- Whether the next scheduled run should try again.
- $status(int) (обязательный)
- HTTP status code, 0 when no response was received.
- $error_code(строка) (обязательный)
- Error code when no response was received.
- $body_bytes(int) (обязательный)
- Size of the snapshot.
Код WC_Tracker::record_send_failure() WC Tracker::record send failure WC 11.3.0
private static function record_send_failure( $retryable, $status, $error_code, $body_bytes ): void {
// The attempt was already counted before the snapshot was built.
$failures = (int) get_option( 'woocommerce_tracker_send_failures', 0 );
$give_up = ! $retryable || self::MAX_CONSECUTIVE_SEND_FAILURES <= $failures;
if ( $give_up ) {
self::finish_snapshot();
} elseif ( true !== wc_string_to_bool( get_option( 'woocommerce_allow_tracking', 'no' ) ) ) {
delete_option( 'woocommerce_tracker_send_failures' );
}
if ( 413 === $status ) {
$message = 'WooCommerce tracker snapshot delivery failed; the snapshot is too large for the service and will not be retried.';
} elseif ( 'json_encode_failure' === $error_code ) {
$message = 'WooCommerce tracker snapshot could not be encoded and will not be retried.';
} elseif ( $give_up ) {
$message = 'WooCommerce tracker snapshot delivery failed; giving up until the next interval.';
} else {
$message = 'WooCommerce tracker snapshot delivery failed; it will be retried on the next run.';
}
wc_get_logger()->warning(
$message,
array(
'source' => 'woocommerce-tracker',
'http_status' => $status,
'error_code' => $error_code,
'failures' => $failures,
'body_bytes' => $body_bytes,
)
);
}