-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Remove additional call to WP_Theme_JSON::_construct
#6271
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
Changes from all commits
a184a82
a3523d0
53a5e2e
bbcc411
002c2cc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | |||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -173,8 +173,7 @@ public static function get_core_data() { | ||||||||||||||||||||||||||||||
| * @param WP_Theme_JSON_Data $theme_json Class to access and update the underlying data. | |||||||||||||||||||||||||||||||
| */ | |||||||||||||||||||||||||||||||
| $theme_json = apply_filters( 'wp_theme_json_data_default', new WP_Theme_JSON_Data( $config, 'default' ) ); | |||||||||||||||||||||||||||||||
| $config = $theme_json->get_data(); | |||||||||||||||||||||||||||||||
| static::$core = new WP_Theme_JSON( $config, 'default' ); | |||||||||||||||||||||||||||||||
swissspidy marked this conversation as resolved.
Show resolved
Hide resolved
|
|||||||||||||||||||||||||||||||
| static::$core = $theme_json->get_theme_json(); | |||||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||||
| return static::$core; | |||||||||||||||||||||||||||||||
| } | |||||||||||||||||||||||||||||||
|
|
@@ -255,8 +254,7 @@ public static function get_theme_data( $deprecated = array(), $options = array() | ||||||||||||||||||||||||||||||
| * @param WP_Theme_JSON_Data $theme_json Class to access and update the underlying data. | |||||||||||||||||||||||||||||||
| */ | |||||||||||||||||||||||||||||||
| $theme_json = apply_filters( 'wp_theme_json_data_theme', new WP_Theme_JSON_Data( $theme_json_data, 'theme' ) ); | |||||||||||||||||||||||||||||||
| $theme_json_data = $theme_json->get_data(); | |||||||||||||||||||||||||||||||
| static::$theme = new WP_Theme_JSON( $theme_json_data ); | |||||||||||||||||||||||||||||||
| static::$theme = $theme_json->get_theme_json(); | |||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There are some linting issues in the committed code, incorrect spacing before the equals signs here. The main reason I'm looking at this though is that a new feature was merged in Gutenberg - WordPress/gutenberg#57908. It was testing fine prior to the changes on these lines, but after the change there's an exception being thrown by this change (I bisected to find it). To repro:
{
"$schema": "https://schemas.wp.org/trunk/theme.json",
"version": 2,
"title": "Variation A",
"blockTypes": [ "core/group", "core/columns", "core/media-text" ],
"styles": {
"color": {
"background": "var(--wp--preset--color--contrast)",
"text": "var(--wp--preset--color--base)"
}
}
}
If you then revert the change on this line(s), the error goes away. I don't have much of an understanding why this causes an issue. It'd be great to understand why it's happening before taking any action. I'll continue looking into it, but any help appreciated, as this'll need to be fixed prior to the 6.6 beta.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @kt-12 @joemcgill @oandregal I think I have an understanding of what's happening, but worth noting I'm not an expert with these theme json classes. The gutenberg codebase hooks into the The core backport for the feature (#6662) does resolve the issue, as it updates But I think there are question marks over what happens when the gutenberg plugin tries to implement new features in the future that extend the theme json.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks @talldan. We had this reported to the related Trac ticket and have created this follow-up PR to address the issue. If you could test it and confirm that it fixes the issue, I can get it committed.
I think this is a very good question. I've had some discussion with @tellthemachines and @oandregal about making the
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I didn't have time to look at this today but will do next week. This smells to a bug we need to fix, for which we have time in the beta period. I'm available and happy to help uncover the issue and prepare a fix. Please, ping me in any related tickets/PR (subscribed to the PRs & trac tickets mentioned).
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I finally got some time to look at this today. Sharing what I know. The flow:
At 4, core receives some data and it expects it to be validated by the consumer of the filter (this is, the consumer uses In the particular case that Dan raised, Gutenberg was able to get more style variations than core had:
At the point of processing the variations, core is unable to find the first three variations, hence the There's a few layers to this issue, and it only happens because Gutenberg is re-triggering the same filters than core ( Unlike this other issue, this is very Gutenberg-specific because it is the result of modifying the metadata/schema of the theme.json. I don't have any more time today to look into solutions, but wanted to share what I know about as soon as possible. I'll do some more testing in the next days to assess the severity and what can we do.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For a different issue, I ended up proposing a change to how "block style variations" defined by the theme are registered at #6756 By doing that, the error reported by Dan no longer happens.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for looking into this @oandregal. It still seems like this is very similar to https://core.trac.wordpress.org/ticket/61112, but seems like the problem is that because core is not converting the It seems wrong that Gutenberg would return an object from these filters that are not compatible with As a matter of process, I think following up on this whole issue should be done in as a part of https://core.trac.wordpress.org/ticket/61112 so this doesn't get lost, so I'm going to summarize this issue on that ticket and update the PR with the new approach I just proposed.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
|||||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||||
| if ( $wp_theme->parent() ) { | |||||||||||||||||||||||||||||||
| // Get parent theme.json. | |||||||||||||||||||||||||||||||
|
|
@@ -387,9 +385,7 @@ public static function get_block_data() { | ||||||||||||||||||||||||||||||
| * @param WP_Theme_JSON_Data $theme_json Class to access and update the underlying data. | |||||||||||||||||||||||||||||||
| */ | |||||||||||||||||||||||||||||||
| $theme_json = apply_filters( 'wp_theme_json_data_blocks', new WP_Theme_JSON_Data( $config, 'blocks' ) ); | |||||||||||||||||||||||||||||||
| $config = $theme_json->get_data(); | |||||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||||
| static::$blocks = new WP_Theme_JSON( $config, 'blocks' ); | |||||||||||||||||||||||||||||||
swissspidy marked this conversation as resolved.
Show resolved
Hide resolved
|
|||||||||||||||||||||||||||||||
| static::$blocks = $theme_json->get_theme_json(); | |||||||||||||||||||||||||||||||
| return static::$blocks; | |||||||||||||||||||||||||||||||
| } | |||||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||||
|
|
@@ -523,8 +519,7 @@ public static function get_user_data() { | ||||||||||||||||||||||||||||||
| * @param WP_Theme_JSON_Data $theme_json Class to access and update the underlying data. | |||||||||||||||||||||||||||||||
| */ | |||||||||||||||||||||||||||||||
| $theme_json = apply_filters( 'wp_theme_json_data_user', new WP_Theme_JSON_Data( $config, 'custom' ) ); | |||||||||||||||||||||||||||||||
| $config = $theme_json->get_data(); | |||||||||||||||||||||||||||||||
| return new WP_Theme_JSON( $config, 'custom' ); | |||||||||||||||||||||||||||||||
| return $theme_json->get_theme_json(); | |||||||||||||||||||||||||||||||
| } | |||||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||||
| /* | |||||||||||||||||||||||||||||||
|
|
@@ -543,8 +538,7 @@ public static function get_user_data() { | ||||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||||
| /** This filter is documented in wp-includes/class-wp-theme-json-resolver.php */ | |||||||||||||||||||||||||||||||
| $theme_json = apply_filters( 'wp_theme_json_data_user', new WP_Theme_JSON_Data( $config, 'custom' ) ); | |||||||||||||||||||||||||||||||
| $config = $theme_json->get_data(); | |||||||||||||||||||||||||||||||
| static::$user = new WP_Theme_JSON( $config, 'custom' ); | |||||||||||||||||||||||||||||||
| static::$user = $theme_json->get_theme_json(); | |||||||||||||||||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. One thing I've noticed after reviewing the Gutenberg PR WordPress/gutenberg#61262 is that this is different in Gutenberg: there, we do
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It looks like #6616 will undo this change.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @talldan w.r.t to keeping both the repos same, that change should be fine. But w.r.t performance we might need to find a better way to do that later on. |
|||||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||||
| return static::$user; | |||||||||||||||||||||||||||||||
| } | |||||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.