Do not attempt to re-save hooks after delivery when not already persisted (#48480)
* Do not re-save hooks not in the DB after delivery * Add changelog * Do not try to deliver (async) webhooks that have been deleted
This commit is contained in:
parent
a5893ac066
commit
24391fba0f
|
@ -0,0 +1,4 @@
|
|||
Significance: patch
|
||||
Type: fix
|
||||
|
||||
Do not create empty webhooks after failure to deliver deleted webhook.
|
|
@ -533,7 +533,10 @@ class WC_Webhook extends WC_Legacy_Webhook {
|
|||
// 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();
|
||||
|
||||
if ( 0 !== $this->get_id() ) {
|
||||
$this->save();
|
||||
}
|
||||
} else {
|
||||
$this->failed_delivery();
|
||||
}
|
||||
|
@ -557,7 +560,9 @@ class WC_Webhook extends WC_Legacy_Webhook {
|
|||
$this->set_failure_count( ++$failures );
|
||||
}
|
||||
|
||||
$this->save();
|
||||
if ( 0 !== $this->get_id() ) {
|
||||
$this->save();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -75,6 +75,11 @@ add_action( 'woocommerce_webhook_process_delivery', 'wc_webhook_process_delivery
|
|||
*/
|
||||
function wc_deliver_webhook_async( $webhook_id, $arg ) {
|
||||
$webhook = new WC_Webhook( $webhook_id );
|
||||
|
||||
if ( 0 === $webhook->get_id() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$webhook->deliver( $arg );
|
||||
}
|
||||
add_action( 'woocommerce_deliver_webhook_async', 'wc_deliver_webhook_async', 10, 2 );
|
||||
|
|
Loading…
Reference in New Issue