Skip to content

Commit

Permalink
(Jetpack)(PHP8)(GB 17.1.3) Make the check around $google_fonts_data
Browse files Browse the repository at this point in the history
…'s array more resilient and return early if key or value is not of the right type (#34382)

* Fallback when $google_fonts_data[fontFamilies] is null to avoid warnings and fatals

* changelog

* Update fix to avoid warnings in `jetpack_google_fonts_filter_out_deprecated_font_data`, make it a bit more DRY

---------

Co-authored-by: Brandon Kraft <[email protected]>
  • Loading branch information
fullofcaffeine and kraftbj committed Nov 30, 2023
1 parent 3cd962a commit 126b8ba
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: compat

Google Fonts: resolve occasional bug resulting in PHP 8 with latest Gutenberg.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ function jetpack_get_google_fonts_data() {
}
}

return $data;
if ( is_array( $data ) && is_array( $data['fontFamilies'] ) ) {
return $data;
}
}

/**
Expand All @@ -56,15 +58,11 @@ function jetpack_get_google_fonts_data() {
* @return object[] The map of the the available Google Fonts.
*/
function jetpack_get_available_google_fonts_map( $google_fonts_data ) {
$font_families = isset( $google_fonts_data ) && isset( $google_fonts_data['fontFamilies'] )
? $google_fonts_data['fontFamilies']
: array();

$jetpack_google_fonts_list = array_map(
function ( $font_family ) {
return $font_family['name'];
},
$font_families
$google_fonts_data['fontFamilies']
);

/** This filter is documented in modules/google-fonts/wordpress-6.3/load-google-fonts.php */
Expand Down

0 comments on commit 126b8ba

Please sign in to comment.