Skip to content
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: migrate get_style_nodes to 6.1 #41262

Closed
wants to merge 3 commits into from

Conversation

ramonjd
Copy link
Member

@ramonjd ramonjd commented May 24, 2022

What?

Migrates WP_Theme_JSON methods that call get_style_nodes() from WP_Theme_JSON_5_9 to WP_Theme_JSON_6_1.

Why?

After #41160, the $selectors argument get_style_nodes() is longer required. See @oandregal's comments in #41217 (comment)

How?

This commit reverts #41217 and migrates WP_Theme_JSON methods that call get_style_nodes() from WP_Theme_JSON_5_9 to WP_Theme_JSON_6_1.

Testing Instructions

Run this branch, ensure the site and post editors work as well as the frontend.

npm run test-unit-php

@ramonjd ramonjd added [Type] Plugin Interoperability Incompatibilities between a specific plugin and the block editor. Close with workaround notes. [Type] Code Quality Issues or PRs that relate to code quality labels May 24, 2022
@ramonjd ramonjd requested a review from draganescu May 24, 2022 01:21
@ramonjd ramonjd self-assigned this May 24, 2022
@ramonjd ramonjd force-pushed the update/refactor-get-style-nodes branch from fe58633 to b31726e Compare May 30, 2022 23:27
@glendaviesnz
Copy link
Contributor

glendaviesnz commented May 31, 2022

Seems to work as advertised to me ... but while testing noted that some styles from theme.json block settings are not being applied in the frontend. Doesn't seem to be this PR as also on trunk, but ok on 6.0, so just tracking down when it was introduced in case related to #41160 changes

Copy link
Contributor

@andrewserong andrewserong left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for exploring this @ramonjd!

Unfortunately, I think the approach might wind up being in conflict with the effort to update the minimum WP version to 5.9 in #41306

In that PR, the 6.0 class inherits from the core WP_Theme_JSON class which will still have the two params for get_style_nodes.

So, with the current approach of class inheritance we might wind up being stuck with the extra params, unless we can think of another way to handle it?

@ramonjd
Copy link
Member Author

ramonjd commented May 31, 2022

So, with the current approach of class inheritance we might wind up being stuck with the extra params, unless we can think of another way to handle it?

Good point, thanks.

I think then I'll rather wait for #41306 to be merged, then see if we can resolve the conflict.

If not, no biggie, #41217 took care of the original PHP warnings regardless.

Thanks for testing @andrewserong and @glendaviesnz

I'll place this PR on the back burner.

@ramonjd ramonjd added the [Status] Blocked Used to indicate that a current effort isn't able to move forward label May 31, 2022
@draganescu draganescu removed their request for review May 31, 2022 07:05
…uired. This commit migrates methods that call get_style_nodes() from WP_Theme_JSON_5_9 to WP_Theme_JSON_6_1, and removes the argument.
@ramonjd ramonjd force-pushed the update/refactor-get-style-nodes branch from b31726e to da15554 Compare July 5, 2022 01:32
@ramonjd ramonjd removed the [Status] Blocked Used to indicate that a current effort isn't able to move forward label Jul 5, 2022
@ramonjd
Copy link
Member Author

ramonjd commented Jul 5, 2022

#41306 has been merged thereby removing the 5.9 compat file completely.

I've rebased this PR.

@ramonjd
Copy link
Member Author

ramonjd commented Jul 5, 2022

Actually, I think I might have to abandon put this enterprise on hold since it's still overwriting the method in Core:

Warning: Declaration of WP_Theme_JSON_6_1::get_style_nodes($theme_json) should be compatible with WP_Theme_JSON::get_style_nodes($theme_json, $selectors = Array) in /var/www/html/wp-content/plugins/gutenberg/lib/compat/wordpress-6.1/class-wp-theme-json-6-1.php

So get_style_nodes will have put up with the unnecessary $selector argument.

We'll need a core patch, so possibly it's best we do it all at once during 6.1.

@ramonjd ramonjd requested a review from scruffian July 5, 2022 01:47
*
* @return array The block nodes in theme.json.
*/
private static function get_block_nodes( $theme_json, $selectors = array() ) {
$selectors = empty( $selectors ) ? static::get_blocks_metadata() : $selectors;
private static function get_block_nodes( $theme_json ) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing params like this could be considered a breaking change.

Copy link
Member Author

@ramonjd ramonjd Dec 8, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for chiming in. This PR is pretty stale and I was going to abandon it.

After the min version of WordPress Gutenberg requires is moved to 6.1, maybe we could revisit it?

There's a PR to bump it to 6.0 at the moment.

* @return array
*/
protected static function get_style_nodes( $theme_json, $selectors = array() ) {
protected static function get_style_nodes( $theme_json ) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ramonjd ramonjd closed this Dec 8, 2022
@youknowriad youknowriad deleted the update/refactor-get-style-nodes branch December 12, 2022 09:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Code Quality Issues or PRs that relate to code quality [Type] Plugin Interoperability Incompatibilities between a specific plugin and the block editor. Close with workaround notes.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants