-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Fix fatal error in Site Editor if a block defines an array of style/editor_style handles #29473
Conversation
Do you know why this used to work? I'm surprised because the doc comments in We'll have to update that documentation in Core and potentially any other code that uses |
This used to work because |
@noisysocks Can you let me know if this is going to be enforced (string/null) or will support an array of handles? If it's going to be string only we'll need to make changes on our side. cc @nerrad |
Personally I think it should support whatever the So I'm in favor of merging this pull request and fixing the jsdocs as well. |
This is definitely a regression, but I don't think we should adjust this. I think array support was only incidental in that the lower level It's specified as a string in the RFC. In the PHP docs, the REST API endpoints, etc... If we allow for an array of handles, that means any downstream code has to handle both the array format and a string format. Whereas if we were to have allowed arrays in the beginning, we would have allowed a string, but upgraded it to an array during registration. I'm also not sure why it is necessary. What are the instances where an array of handles is needed instead of adding the additional handles as dependencies to the original handle? |
Good points Timothy. @mikejolley I think we had a discussion on this and offhand we couldn't recall why we pass two dependency handles in to the registration API. I agree, it seems like it's something that could be addressed in how WooCommerce blocks registers things. Mike, any additional thoughts? |
Yeah we can update our usage. Closing this, I don't know if GB should do some type checking on these values instead of breaking though, even if arrays are not supported ¯_(ツ)_/¯ |
Description
We're currently working on making WooCommerce Blocks compatible with FSE, and one issue we've come across is the way in which handles are being merged in
gutenberg_extend_block_editor_styles_html
here:gutenberg/lib/client-assets.php
Lines 718 to 728 in da8555d
Some of our blocks do not have a single editor_script handle, for example here we include the block styles, and the vendor styles, so the handle is an array, not a string.
This results in a white screen/fatal error when loading up the Site Editor (array to string conversion).
To fix this, this PR checks to see if a handle is a string or an array, and merges it appropriately.
How has this been tested?
Types of changes
This is a Bug fix for the style handle handler.
@nerrad recommended I ping @noisysocks in case this fix needs porting to WP 5.7.
Checklist: