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.
This commit is contained in:
JD 2018-10-03 16:40:49 +01:00 committed by GitHub
parent 8d1daeeaf9
commit b0b2b34884
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 1 deletions

View File

@ -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 {