From b0b2b34884462a336f85f42f3668093493d26aea Mon Sep 17 00:00:00 2001 From: JD Date: Wed, 3 Oct 2018 16:40:49 +0100 Subject: [PATCH 1/2] Avoid treating HTTP 301 and 302 Codes as Failures As per: https://github.com/woocommerce/woocommerce/issues/21490 Change the definition of a Webhook Delivery Failure to exclude HTTP/301 and HTTP/302 responses. This allows webhook handlers (such as Google Apps Script) to avoid breaching failure limits and disabling webhooks. --- includes/class-wc-webhook.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/includes/class-wc-webhook.php b/includes/class-wc-webhook.php index bf4cf9dc1c8..1bd278ff010 100644 --- a/includes/class-wc-webhook.php +++ b/includes/class-wc-webhook.php @@ -442,7 +442,8 @@ class WC_Webhook extends WC_Legacy_Webhook { ); // Track failures. - if ( intval( $response_code ) >= 200 && intval( $response_code ) < 300 ) { + // Check for a success, which is a 2xx, 301 or 302 Response Code + if ( intval( $response_code ) >= 200 && intval( $response_code ) < 303 ) { $this->set_failure_count( 0 ); $this->save(); } else { From 0871ad86272bdaaa533edde8e35d45479a72d9b4 Mon Sep 17 00:00:00 2001 From: JD Date: Wed, 3 Oct 2018 21:38:53 +0100 Subject: [PATCH 2/2] Update class-wc-webhook.php --- includes/class-wc-webhook.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/class-wc-webhook.php b/includes/class-wc-webhook.php index 1bd278ff010..5306f6e1b7e 100644 --- a/includes/class-wc-webhook.php +++ b/includes/class-wc-webhook.php @@ -442,7 +442,7 @@ class WC_Webhook extends WC_Legacy_Webhook { ); // Track failures. - // Check for a success, which is a 2xx, 301 or 302 Response Code + // Check for a success, which is a 2xx, 301 or 302 Response Code. if ( intval( $response_code ) >= 200 && intval( $response_code ) < 303 ) { $this->set_failure_count( 0 ); $this->save();