From 484946dc1312ac350b9d5fe6884829199607361d Mon Sep 17 00:00:00 2001 From: Vicente Canales Date: Fri, 10 Nov 2023 16:48:32 -0300 Subject: [PATCH 1/3] Make sure theme families are array before merging Follow up to https://github.com/WordPress/gutenberg/pull/55981 --- lib/experimental/fonts-api/class-wp-fonts-resolver.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/experimental/fonts-api/class-wp-fonts-resolver.php b/lib/experimental/fonts-api/class-wp-fonts-resolver.php index f2299c7c368311..abfe9eb68782f9 100644 --- a/lib/experimental/fonts-api/class-wp-fonts-resolver.php +++ b/lib/experimental/fonts-api/class-wp-fonts-resolver.php @@ -214,7 +214,7 @@ private static function get_settings() { // Merge the variation settings with the global settings. $settings['typography']['fontFamilies']['theme'] = array_merge( - $settings['typography']['fontFamilies']['theme'], + $settings['typography']['fontFamilies']['theme'] ?? array(), $variation_font_families ); From 0e33f23a4f858c94aa41ca82057fdf1b2ea22696 Mon Sep 17 00:00:00 2001 From: arthur Date: Mon, 13 Nov 2023 12:17:55 +0800 Subject: [PATCH 2/3] Fix fatal error in WP_Fonts_Resolver::get_settings() --- .../fonts-api/class-wp-fonts-resolver.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/experimental/fonts-api/class-wp-fonts-resolver.php b/lib/experimental/fonts-api/class-wp-fonts-resolver.php index abfe9eb68782f9..c5931db523505c 100644 --- a/lib/experimental/fonts-api/class-wp-fonts-resolver.php +++ b/lib/experimental/fonts-api/class-wp-fonts-resolver.php @@ -200,11 +200,6 @@ private static function get_settings() { if ( $set_theme_structure ) { $set_theme_structure = false; $settings = static::set_tyopgraphy_settings_array_structure( $settings ); - - // Initialize the font families from settings if set and is an array, otherwise default to an empty array. - if ( ! isset( $settings['typography']['fontFamilies']['theme'] ) || ! is_array( $settings['typography']['fontFamilies']['theme'] ) ) { - $settings['typography']['fontFamilies']['theme'] = array(); - } } // Initialize the font families from variation if set and is an array, otherwise default to an empty array. @@ -219,7 +214,12 @@ private static function get_settings() { ); // Make sure there are no duplicates. - $settings['typography']['fontFamilies'] = array_unique( $settings['typography']['fontFamilies'] ); + $settings['typography']['fontFamilies'] = array_unique( $settings['typography']['fontFamilies'], SORT_REGULAR ); + + // The font families from settings might become null after running the `array_unique`. + if ( ! isset( $settings['typography']['fontFamilies']['theme'] ) || ! is_array( $settings['typography']['fontFamilies']['theme'] ) ) { + $settings['typography']['fontFamilies']['theme'] = array(); + } } return $settings; From fab55e85873abe85fbe8a267225c951fd73288f4 Mon Sep 17 00:00:00 2001 From: Vicente Canales Date: Mon, 13 Nov 2023 09:52:23 -0300 Subject: [PATCH 3/3] Remove unnecessary check Made unnecessary by 913d5dd88c8026bca513844e6eb745cfd62cc2a8 --- lib/experimental/fonts-api/class-wp-fonts-resolver.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/experimental/fonts-api/class-wp-fonts-resolver.php b/lib/experimental/fonts-api/class-wp-fonts-resolver.php index c5931db523505c..efa66839cd39ca 100644 --- a/lib/experimental/fonts-api/class-wp-fonts-resolver.php +++ b/lib/experimental/fonts-api/class-wp-fonts-resolver.php @@ -209,7 +209,7 @@ private static function get_settings() { // Merge the variation settings with the global settings. $settings['typography']['fontFamilies']['theme'] = array_merge( - $settings['typography']['fontFamilies']['theme'] ?? array(), + $settings['typography']['fontFamilies']['theme'], $variation_font_families );