#60613 closed defect (bug) (fixed)
Theme JSON CSS var preset resolution: check for null values
| Reported by: | ramonopoly | Owned by: | youknowriad |
|---|---|---|---|
| Priority: | normal | Milestone: | 6.5 |
| Component: | Themes | Version: | 6.5 |
| Severity: | normal | Keywords: | has-patch has-unit-tests gutenberg-merge |
| Cc: | Focuses: |
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.
3 years ago
#1
#2
@
3 years 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:
3 years ago
#3
@youknowriad I think this one is ready once the nits are addressed.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
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_wpThemeJsonTrac ticket: https://core.trac.wordpress.org/ticket/60613