#60613 closed defect (bug) (fixed)
Theme JSON CSS var preset resolution: check for null values
Reported by: | ramonopoly | Owned by: | youknowriad |
---|---|---|---|
Milestone: | 6.5 | Priority: | normal |
Severity: | normal | Version: | 6.5 |
Component: | Themes | Keywords: | has-patch has-unit-tests gutenberg-merge |
Focuses: | Cc: |
Description
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: Theme JSON: Check for null values to cater for blockGap
Change History (7)
This ticket was mentioned in PR #6169 on WordPress/wordpress-develop by @ramonopoly.
10 months ago
#1
#2
@
10 months ago
I added 6.5 to this ticket - hopefully it's not controversial.
Fine to be punted to 6.6.
@get_dave commented on PR #6169:
10 months ago
#3
@youknowriad I think this one is ready once the nits are addressed.
#4
@
10 months ago
- Component changed from General to Themes
- Owner set to youknowriad
- Status changed from new to reviewing
Syncs changes from
When resolving theme.json preset variables, add a check to make sure the value is not empty before we run it through
strpos()
andpreg_match_all()
.Run the tests:
npm run test:php -- --filter Tests_Theme_wpThemeJson
Trac ticket: https://core.trac.wordpress.org/ticket/60613