From c01fcf389ae50cc3e33ca14a23c39b14246588df Mon Sep 17 00:00:00 2001 From: Brent Nef Date: Tue, 2 Feb 2021 12:41:08 -0800 Subject: [PATCH 1/2] Respect the $limit parameter (0) --- plugins/woocommerce/includes/wc-webhook-functions.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/woocommerce/includes/wc-webhook-functions.php b/plugins/woocommerce/includes/wc-webhook-functions.php index bc1d15998eb..25dc7509107 100644 --- a/plugins/woocommerce/includes/wc-webhook-functions.php +++ b/plugins/woocommerce/includes/wc-webhook-functions.php @@ -164,13 +164,13 @@ function wc_load_webhooks( $status = '', $limit = null ) { $loaded = 0; foreach ( $webhooks as $webhook_id ) { - $webhook = new WC_Webhook( $webhook_id ); - $webhook->enqueue(); - $loaded ++; - if ( ! is_null( $limit ) && $loaded >= $limit ) { break; } + + $webhook = new WC_Webhook( $webhook_id ); + $webhook->enqueue(); + $loaded ++; } return 0 < $loaded; From 40a1988f24b26ddbf56019d735f93eaf1f68f746 Mon Sep 17 00:00:00 2001 From: Brent Nef Date: Tue, 2 Feb 2021 14:55:04 -0800 Subject: [PATCH 2/2] Add tests. --- .../tests/legacy/unit-tests/webhooks/functions.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/plugins/woocommerce/tests/legacy/unit-tests/webhooks/functions.php b/plugins/woocommerce/tests/legacy/unit-tests/webhooks/functions.php index 521011fa5c3..b36fb6ef23e 100644 --- a/plugins/woocommerce/tests/legacy/unit-tests/webhooks/functions.php +++ b/plugins/woocommerce/tests/legacy/unit-tests/webhooks/functions.php @@ -172,6 +172,10 @@ class WC_Tests_Webhook_Functions extends WC_Unit_Test_Case { $webhook_one = $this->create_webhook( 'action.woocommerce_one_test' ); $webhook_two = $this->create_webhook( 'action.woocommerce_two_test' ); + $this->assertFalse( wc_load_webhooks( '', 0 ) ); + $this->assertFalse( isset( $wp_filter['woocommerce_one_test'] ) ); + $this->assertFalse( isset( $wp_filter['woocommerce_two_test'] ) ); + $this->assertTrue( wc_load_webhooks( '', 1 ) ); $this->assertFalse( isset( $wp_filter['woocommerce_one_test'] ) ); $this->assertTrue( isset( $wp_filter['woocommerce_two_test'] ) );