[wp-trac] [WordPress Trac] #60613: Theme JSON CSS var preset resolution: check for null values
WordPress Trac
noreply at wordpress.org
Fri Feb 23 01:00:09 UTC 2024
#60613: Theme JSON CSS var preset resolution: check for null values
-------------------------+-------------------------------------------------
Reporter: ramonopoly | Owner: (none)
Type: defect | Status: new
(bug) |
Priority: normal | Milestone: 6.5
Component: General | Version: trunk
Severity: normal | Keywords: has-patch has-unit-tests gutenberg-
Focuses: | merge
-------------------------+-------------------------------------------------
When using `wp_get_global_styles()` with the `resolve-variables` flag like
this —
`wp_get_global_styles( array( 'typography', 'fontSize' ), array(
'block_name' => 'core/search', 'transforms' => array( 'resolve-variables'
) ) );`
It's possible to trigger the following error:
-----
''Deprecated: strpos(): Passing null to parameter 1 ($haystack) of type
string is deprecated in
Deprecated: preg_match_all(): Passing null to parameter 2 ($subject) of
type string is deprecated''
----
The complaint is about passing a null value to `strpos()` and
`preg_match_all()` in `WP_Theme_JSON::convert_variables_to_value`
`wp_get_global_styles` attempt to resolve variables using merged data from
`WP_Theme_JSON_Resolver`.
`WP_Theme_JSON_Resolver::get_block_data()` sets `blockGap` for supported
blocks to `null` if the value is not defined.
Because `WP_Theme_JSON_Gutenberg::convert_variables_to_value` is expecting
strings as values, it will trigger the error in this case.
Gutenberg PR: [https://github.com/WordPress/gutenberg/pull/59258 Theme
JSON: Check for null values to cater for blockGap]
--
Ticket URL: <https://core.trac.wordpress.org/ticket/60613>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list