-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Global Styles: Fix handling of booleans when stabilizing block supports #67552
Global Styles: Fix handling of booleans when stabilizing block supports #67552
Conversation
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
efbbc5e
to
92e48c3
Compare
Flaky tests detected in 92e48c3. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/12155128978
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the follow up!
To test I updated the group block's border support to stable, e.g.,
"border": {
...
},
Then added a filter that sets __experimentalBorder
to false
:
function disable_group_borders( $args ) {
if ( 'core/group' === $args['name'] ) {
_wp_array_set( $args, array( 'supports', '__experimentalBorder' ), false );
}
return $args;
}
add_filter( 'register_block_type_args', 'disable_group_borders', 20 );
In trunk I get the fatal error:
Fatal error: Uncaught TypeError: array_merge(): Argument #2 must be of type array, bool given in /var/www/html/wp-content/plugins/gutenberg/lib/compat/wordpress-6.8/blocks.php:128
In this PR, the border support is disabled as expected.
One thing I noticed while testing is that setting border supports to function disable_group_borders( $args ) {
if ( 'core/group' === $args['name'] ) {
_wp_array_set( $args, array( 'supports', '__experimentalBorder' ), true ); // or stable 'border' as well.
}
return $args;
}
add_filter( 'register_block_type_args', 'disable_group_borders', 20 ); Is that expected? This is the state in trunk too, so nothing to fix in this PR as far as I'm aware. |
I've tracked this down to a regression introduced when the border panel was combined for the block inspector and global styles #48636. The combined border panel assumed it only had to check the So the good news is that the recent block support stabilization didn't break it. The bad news is we broke that a long time ago! I'll get this PR merged and spin up something fresh to fix that regression. I have a suspicion the merging of panels for all the other block supports, e.g. typography, will have broken the same thing 😅 |
92e48c3
to
deb49a2
Compare
Thanks for taking the time to investigate. And excellent detective work.
If you have time, thanks! Let me know if I can help. |
Thanks @ramonjd, might need it! To make all the block supports consistent is looking like a bigger job than I hoped.
This gets murkier though when we look at the theme.json schema, particularly given how this schema has been regularly out of date and doesn't contain experimental supports e.g. border.
I had a quick look and didn't spot any submitted issues around using boolean values to toggle on all features for block supports. It might not be something that is currently leaned on by extenders. They might have also just been forced into object-based configs because of bugs 🤷 @youknowriad If you have a moment, it'd be great to tap your wisdom on what the desired outcome here should be. Do we want to support boolean opt-in/out of block support features or should we remove the fragments of that support that remain? If there's no obvious answer, I can spin up a dedicated issue for broader discussion. |
I think it's a nice little touch, but yeah maybe a hard sell for "color" because of the backwards compatibility unless we do an apiV4 at some point. |
For the supports that never worked that way, I suppose we can categorize it as a logical inconsistency and not a blocker for anything. I really appreciate the investigation and reporting here! We could also be techocratic about it and say, even though Dimensions, Borders and Spacing regressed more than a year ago, there was nothing in the spec to say they should have worked that way. Given the time span since the "regression" and today, and the lack of complaints I think it'd be possible re-introduce as an enhancement in a non-urgent fashion. At least, that's my take away. You did all the hard work 😅 - what you think? |
Quick update: As discussed in #67729 (comment), the approach to block support stabilization needs more time so will likely be punted from 6.8. There is a revert PR available (#68163) and anyone interested in stabilized block supports is advised to follow that for the latest 🙏 |
@aaronrobertshaw - As mentioned in this PR #68163 do we need to revert all the changes in this PR? After reverting the changes, how do we test it? Please advice in this regards. Thanks in advance. |
Yes, this PR only relates to fixing the use of boolean values for entire block supports while stabilizing them. Reverting it completely forms part of taking things back to where they were before recent stabilization efforts.
Test instructions are already on the revert PR. They effectively consist of making sure that block supports function as expected, this includes skipping serialization and default controls config. |
…alization and default controls supports (#68163) * Revert "Global Styles: Fix handling of booleans when stabilizing block supports (#67552)" This reverts commit 4335c45. * Revert "Block Supports: Extend stabilization to common experimental block support flags (#67018)" This reverts commit 5513d7a. * Revert "Borders: Stabilize border block supports within block processing (#66918)" This reverts commit b5ee9da. * Revert "Process Block Type: Copy deprecation to a new object instead of mutating when stabilizing supports (#66849)" This reverts commit 457fcf8. * Revert "Typography: Stabilize typography block supports within block processing (#63401)" This reverts commit 48341a1. Co-authored-by: aaronrobertshaw <[email protected]> Co-authored-by: ramonjd <[email protected]> Co-authored-by: talldan <[email protected]>
Related:
What?
Fixes issue introduced by #67018 resulting in mishandling of boolean config values for experimental block supports that are being stabilized e.g.
__experimentalBorder
.This problem was raised on the backport PR for block support stabilization.
Why?
Without a fix, this bug will throw a fatal error when experimental block supports with boolean config values are stabilized.
How?
Testing Instructions
register_block_type_args
filter that replaces thesupports.__experimentalBorder
config with a boolean true or falseborder
key that uses a boolean value.