Closed jhnstn closed 1 month ago
Originally reported here: 8470578-zd-a8c
Support References
This comment is automatically generated. Please do not edit it.
@Automattic/lego Is that something you could look at?
Thank you!
Thanks @jeherve.
@arthur791004 -- since it looks like an easy fix, and you're the one most familiar with this area, would mind looking at it sometime next week? Let's still prioritize the ETK migration, though. cc: @taipeicoder
I opened a PR with the fix. I added tests but was having a hard time running them locally. I'll be AFK next week so you can take over that PR.
Edit: Tests are passing
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#L93Trying 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