PTK: Check if theres a scheduled action before logging warning. (#51143)

* Check if there is a scheduled action before logging warning
This commit is contained in:
Tom Cafferkey 2024-09-04 14:23:20 +01:00 committed by GitHub
parent b618f81c6d
commit c074c5580b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 12 additions and 3 deletions

View File

@ -0,0 +1,4 @@
Significance: patch
Type: fix
Only log PTK error if no action has been scheduled

View File

@ -141,9 +141,14 @@ class BlockPatterns {
$patterns = $this->ptk_patterns_store->get_patterns();
if ( empty( $patterns ) ) {
// 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;
}