diff --git a/plugins/woocommerce/changelog/fix-register-ptk-patterns-warning-log b/plugins/woocommerce/changelog/fix-register-ptk-patterns-warning-log new file mode 100644 index 00000000000..0f236c0c0fe --- /dev/null +++ b/plugins/woocommerce/changelog/fix-register-ptk-patterns-warning-log @@ -0,0 +1,4 @@ +Significance: patch +Type: fix + +Only log PTK error if no action has been scheduled diff --git a/plugins/woocommerce/src/Blocks/BlockPatterns.php b/plugins/woocommerce/src/Blocks/BlockPatterns.php index 362fdae0446..70b7f137db9 100644 --- a/plugins/woocommerce/src/Blocks/BlockPatterns.php +++ b/plugins/woocommerce/src/Blocks/BlockPatterns.php @@ -141,9 +141,14 @@ class BlockPatterns { $patterns = $this->ptk_patterns_store->get_patterns(); if ( empty( $patterns ) ) { - wc_get_logger()->warning( - __( 'Empty patterns received from the PTK Pattern Store', 'woocommerce' ), - ); + // By only logging when patterns are empty and no fetch is scheduled, + // we ensure that warnings are only generated in genuinely problematic situations, + // such as when the pattern fetching mechanism has failed entirely. + if ( ! as_has_scheduled_action( 'fetch_patterns' ) ) { + wc_get_logger()->warning( + __( 'Empty patterns received from the PTK Pattern Store', 'woocommerce' ), + ); + } return; }