Google Fonts: formating the fontFamily block attribute fails if it's not a string #38311
Labels
Customer Report
Issues or PRs that were reported via Happiness. Previously known as "Happiness Request".
[Feature] Google Fonts
[Platform] Atomic
[Plugin] Jetpack
Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/
[Pri] High
[Status] Priority Review Triggered
The guild in charge of triage has been notified of this issue in Slack
Triaged
[Type] Bug
When a feature is broken and / or not performing as intended
Impacted plugin
Jetpack
Quick summary
Any block can add the attribute
fontFamily
as something other than a string.However,
format_font()
method assumes the attribute is a string https://github.com/Automattic/jetpack/blame/trunk/projects/plugins/jetpack/modules/google-fonts/current/class-jetpack-google-font-face.php#L149This can cause issues when trying to render a block which can in turn prevent updating a post.
This was found while trying to solve an issue where a widget contained a block that used
fontFamily
object attribute.The specific block attribute can be seen here https://plugins.trac.wordpress.org/browser/easy-quotes/trunk/build/block.json#L93
Trying to remove that block from a widget results in the error
PHP Fatal error: Uncaught TypeError: strtolower(): Argument #1 ($string) must be of type string, array given in /wordpress/plugins/jetpack/13.7-a.1/modules/google-fonts/current/class-jetpack-google-font-face.php:149
Steps to reproduce
Steps
fontFamily
that is not a string ( https://wordpress.org/plugins/easy-quotes/ for example )A clear and concise description of what you expected to happen.
The page should be saved
What actually happened
The API returns an error and the post is not saved.
Impact
One
Available workarounds?
No but the platform is still usable
Platform (Simple and/or Atomic)
Atomic
Logs or notes
Probably just need to do a string check here https://github.com/Automattic/jetpack/blame/trunk/projects/plugins/jetpack/modules/google-fonts/current/class-jetpack-google-font-face.php#L124
The text was updated successfully, but these errors were encountered: