-
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
theme.json: Fix theme_has_support() #30479
Conversation
Size Change: 0 B Total Size: 1.42 MB ℹ️ View Unchanged
|
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.
This seems a simple change. But it's a pity that we need it though 😄
Maybe we should leave a comment why this is needed?
@@ -124,7 +124,7 @@ function _gutenberg_get_template_files( $template_type ) { | |||
* @return array Template. | |||
*/ | |||
function _gutenberg_add_template_part_area_info( $template_info ) { | |||
if ( WP_Theme_JSON_Resolver::theme_has_support() ) { | |||
if ( WP_Theme_JSON_Resolver::theme_has_support( $template_info['slug'] ) ) { |
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.
The function doesn't accept any arguments.
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! Leftover from a previous iteration. I'll remove it.
Heads-up, some new findings being discussed over at the issue. tl;dr -- this problem might be specific to unit tests. |
Actually, I prefer this PR over #30686 The #30686 PR doesn't really solve the problem, it's a workaround to make it work. I think changing the theme programmatically (during runtime) is a legit use case, and to make sure this part of the code returns the correct value we need to make sure it works with that use case. So +1 for this over #30686 |
I'm not totally sure that's true. 🤔
That's true, but I think that the values that #30686 sets don't really preclude that; it's still possible for individual unit tests to change the theme (and a number of them actually do). IIUC, the (That said, it's true that #30686 causes a few other unit tests to fail; we'll need to figure out if that's legit or not.) |
Have an alternative at #30830 See rationale #30478 (comment) |
Closing in favor of #30830, which seems like a better solution (and doesn't cause existing unit tests to fail 😬 ) |
Description
Fixes #30478. See there for details.
How has this been tested?
Read the explanation in #30478. Then, have a look at #30045, and verify that its unit tests are currently failing.
Check out #30045's branch (
update/wp-env-tt1-blocks-0-4-4
), and runIt should fail.
Now cherry-pick the commits from this branch. Restart
wp-env
(in order to trigger the upgrade to TT1 Blocks v0.4.5), and run the test again.This time, it should pass.
Maybe @Addison-Stavlo @david-szabo97 et al can come up with a simpler way to demonstrate this -- I'm not sure where (e.g. in the UI) the template part area is currently exposed (and broken by the underlying bug).
TODO
Note that if you run all PHP unit tests (
npm run test-unit-php
) after cherry-picking, there's another test failure:I believe that is probably a bug that is exposed by this fix (and that also needs to be addressed).
Types of changes
Bug fix.