Opened 6 months ago
Closed 4 months ago
#64848 closed defect (bug) (fixed)
WP_Theme_JSON: Prevent implicit coercion in to_ruleset
| Reported by: | ramonopoly | Owned by: | ramonopoly |
|---|---|---|---|
| Priority: | normal | Milestone: | 7.1 |
| Component: | Themes | Version: | 5.8 |
| Severity: | minor | Keywords: | has-patch gutenberg-merge has-unit-tests |
| Cc: | Focuses: |
Description
WP_Theme_JSON::to_ruleset used string concatenation ($element['name'] . ': ' . $element['value'] . ';'), so PHP implicitly coerced non-string values (e.g. booleans → '1'/'', arrays → 'Array'). That could emit invalid or misleading CSS.
I caught this while debugging the test_get_styles_with_appearance_tools() test, which was outputting values like gap: 1 where 1 was the result of coercing a bool.
The bool was the block support value, not a gap value.
Attachments (1)
Change History (18)
This ticket was mentioned in PR #11236 on WordPress/wordpress-develop by @ramonopoly.
6 months ago
#1
@isabel_brison commented on PR #11236:
6 months ago
#2
This LGTM but if we're aiming for 7.1 we'll have to wait until the 7.0 release branch is created at RC1 to commit it to trunk.
@isabel_brison commented on PR #11236:
6 months ago
#3
Also, PHP tests seem to be complaining about your use of setAccessible()
There was 1 error: 1) Tests_Theme_wpThemeJson::test_to_ruleset_skips_non_scalar_values_and_casts_numerics Method ReflectionMethod::setAccessible() is deprecated since 8.5, as it has no effect since PHP 8.1 /var/www/tests/phpunit/tests/theme/wpThemeJson.php:7066 /var/www/vendor/bin/phpunit:122
@ramonopoly commented on PR #11236:
6 months ago
#4
PHP tests seem to be complaining about your use of setAccessible()
Argh, < 8.5 wants it, > 8.5 hates it. 🤣
This LGTM but if we're aiming for 7.1 we'll have to wait until the 7.0 release branch is created at RC1 to commit it to trunk.
Thanks for the heads up. I'll leave it brewing until then.
#5
@
4 months ago
The warning mentioned in #3 is appearing for a split second when you edit a post under PHP 8.5.1 (WP 7.0-RC3-62340, WP_DEBUG set to true)
EDIT: Gutenberg Plugin 23.1.1 must be installed/active
#7
@
4 months ago
Thanks @Presskopp I suspect it's unrelated directly to this issue.
I created a PR in GB to wrap those calls
@ramonopoly commented on PR #11236:
4 months ago
#9
Committed in r62347 and 8a4a40ee7ce5d1bda592dc5213c4338cae1733fe
#10
@
4 months ago
- Resolution fixed
- Status closed → reopened
Reopening. There's a block on committing to trunk until 7.0. I'll revert
@ramonopoly commented on PR #11236:
4 months ago
#11
Reopening. There's a block on committing to trunk until 7.0. I'll revert
@ramonopoly commented on PR #11236:
4 months ago
#12
Revert patch here:
This ticket was mentioned in PR #11791 on WordPress/wordpress-develop by @ramonopoly.
4 months ago
#13
Reverts:
And therefore https://core.trac.wordpress.org/changeset/62347
This is because there's a block on commits to trunk for 7.1 patches until 7.0 is released.
Related trac ticket: core.trac.wordpress.org/ticket/64848
@ramonopoly commented on PR #11791:
4 months ago
#15
Committed in r62348 / 8b45167597be0efe35083e2a1ca620caee66fc1f
@ramonopoly commented on PR #11236:
4 months ago
#16
A commit was made that fixes the Trac ticket referenced in the description of this pull request.
This still needs to go in, bot. It was reverted.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
Brings over changes from:
to_rulesetused string concatenation ($element['name'] . ': ' . $element['value'] . ';'), so PHP implicitly coerced non-string values (e.g. booleans →'1'/'', arrays →'Array'). That could emit invalid or misleading CSS.At the same time, pass a
styletheme.json path intest_get_styles_with_appearance_tools()to simulate a style node. Before it wassettings.## The fix
## Testing
Tests should pass!
Trac ticket: https://core.trac.wordpress.org/ticket/64848
## Use of AI Tools
Diagnostics