From b18fb316bd44a8cb00e2de79b8ce2981e4eb144d Mon Sep 17 00:00:00 2001 From: arunshenoy99 Date: Tue, 19 Mar 2024 14:07:23 +0530 Subject: [PATCH 1/3] Add a null check --- endurance-page-cache.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/endurance-page-cache.php b/endurance-page-cache.php index 902d528..3688a47 100644 --- a/endurance-page-cache.php +++ b/endurance-page-cache.php @@ -756,6 +756,10 @@ public function purge_cdn_single( $pattern = '' ) { */ public function should_throttle( $uri, $type ) { + if ( is_null( $uri ) ) { + return true; + } + $should_throttle = false; $this->should_update_throttled_items = true; From b1e7bdbb10dcf821f49fb8c679344530c7393055 Mon Sep 17 00:00:00 2001 From: arunshenoy99 Date: Tue, 19 Mar 2024 14:11:17 +0530 Subject: [PATCH 2/3] Move the null check before hashing. --- endurance-page-cache.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/endurance-page-cache.php b/endurance-page-cache.php index 3688a47..0c6c953 100644 --- a/endurance-page-cache.php +++ b/endurance-page-cache.php @@ -756,14 +756,14 @@ public function purge_cdn_single( $pattern = '' ) { */ public function should_throttle( $uri, $type ) { - if ( is_null( $uri ) ) { - return true; - } - $should_throttle = false; $this->should_update_throttled_items = true; + if ( is_null( $uri ) ) { + return true; + } + $hash = md5( $uri ); if ( isset( $this->throttled[ $type ], $this->throttled[ $type ][ $hash ] ) ) { From 9cc21e2a199f88592b5bf6a290b419e3ce0e2758 Mon Sep 17 00:00:00 2001 From: arunshenoy99 Date: Tue, 19 Mar 2024 22:27:12 +0530 Subject: [PATCH 3/3] Move check to the beginning of the function --- endurance-page-cache.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/endurance-page-cache.php b/endurance-page-cache.php index 0c6c953..3688a47 100644 --- a/endurance-page-cache.php +++ b/endurance-page-cache.php @@ -756,14 +756,14 @@ public function purge_cdn_single( $pattern = '' ) { */ public function should_throttle( $uri, $type ) { - $should_throttle = false; - - $this->should_update_throttled_items = true; - if ( is_null( $uri ) ) { return true; } + $should_throttle = false; + + $this->should_update_throttled_items = true; + $hash = md5( $uri ); if ( isset( $this->throttled[ $type ], $this->throttled[ $type ][ $hash ] ) ) {