From fca25d5e2fb4c283800d4e7b62799828f2032160 Mon Sep 17 00:00:00 2001 From: Vara Date: Thu, 7 Sep 2023 07:08:48 +0530 Subject: [PATCH 1/3] Add check for block_patterns before using concatenation --- includes/Data/Patterns.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/includes/Data/Patterns.php b/includes/Data/Patterns.php index 849a02d0f..79015a227 100644 --- a/includes/Data/Patterns.php +++ b/includes/Data/Patterns.php @@ -392,7 +392,11 @@ public static function get_theme_step_patterns_from_step( $step, $squash = false ); continue; } - $block_patterns .= self::cleanup_wp_grammar( $pattern['content'] ); + if (isset($block_patterns)) { + $block_patterns .= self::cleanup_wp_grammar( $pattern['content'] ); + } else { + $block_patterns = self::cleanup_wp_grammar( $pattern['content'] ); + } } if ( isset( self::get_theme_step_filters()[ $active_theme ][ $step ] ) ) { From e335c874ee24e923d730d4041e8b159e5764e294 Mon Sep 17 00:00:00 2001 From: mr-vara Date: Thu, 7 Sep 2023 07:30:46 +0530 Subject: [PATCH 2/3] Fix lint issues --- includes/Data/Patterns.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/Data/Patterns.php b/includes/Data/Patterns.php index 79015a227..8a587788b 100644 --- a/includes/Data/Patterns.php +++ b/includes/Data/Patterns.php @@ -392,7 +392,7 @@ public static function get_theme_step_patterns_from_step( $step, $squash = false ); continue; } - if (isset($block_patterns)) { + if ( isset( $block_patterns ) ) { $block_patterns .= self::cleanup_wp_grammar( $pattern['content'] ); } else { $block_patterns = self::cleanup_wp_grammar( $pattern['content'] ); From c0ebb549cc2adf4616933097267bf87e18e9c4b8 Mon Sep 17 00:00:00 2001 From: Vara Date: Thu, 21 Sep 2023 16:51:11 +0530 Subject: [PATCH 3/3] Update defensive check in Patterns --- includes/Data/Patterns.php | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/includes/Data/Patterns.php b/includes/Data/Patterns.php index 8a587788b..c0950b65e 100644 --- a/includes/Data/Patterns.php +++ b/includes/Data/Patterns.php @@ -358,6 +358,7 @@ public static function get_theme_step_patterns_from_step( $step, $squash = false } $pattern_slugs = self::get_theme_step_patterns()[ $active_theme ][ $step ]; + $block_patterns = $squash ? '' : array(); foreach ( array_keys( $pattern_slugs ) as $pattern_slug ) { if ( true !== $pattern_slugs[ $pattern_slug ]['active'] ) { @@ -392,11 +393,7 @@ public static function get_theme_step_patterns_from_step( $step, $squash = false ); continue; } - if ( isset( $block_patterns ) ) { - $block_patterns .= self::cleanup_wp_grammar( $pattern['content'] ); - } else { - $block_patterns = self::cleanup_wp_grammar( $pattern['content'] ); - } + $block_patterns .= self::cleanup_wp_grammar( $pattern['content'] ); } if ( isset( self::get_theme_step_filters()[ $active_theme ][ $step ] ) ) {