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: adding optional argument to get_style_nodes() #41218

Closed
wants to merge 1 commit into from

Conversation

ramonjd
Copy link
Member

@ramonjd ramonjd commented May 23, 2022

What?

Adding an optional, second $selectors argument to get_style_nodes() to match the original function signature in 5.9.

Props to @torounit, who discovered the bug and came up with the original fix in #41217

This PR includes an additional type check in filter_out_block_nodes() to avoid the PHPCodeSniffer error:

Fatal error: Uncaught TypeError: vsprintf(): Argument #2 ($values) must be of type array, string given in /app/vendor/squizlabs/php_codesniffer/src/Files/File.php:1056

Why?

#41160 refactored get_style_nodes() so that the $selectors argument was no longer required. This was incompatible with the original method in 5.9.

How?

Adding an optional $selectors argument to keep the linters happy.

Testing Instructions

Fire up this branch and run through the testing scenarios in #41160

Ensure you don't encounter the error:

Warning: Declaration of WP_Theme_JSON_6_1::get_style_nodes($theme_json) should be compatible with WP_Theme_JSON_5_9::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 on line 124

@ramonjd ramonjd changed the title Testing only. Will delete this branch. Theme JSON: adding optional argument to get_style_nodes() May 23, 2022
@ramonjd ramonjd self-assigned this May 23, 2022
@ramonjd ramonjd added [Type] Bug An existing feature does not function as intended [Type] Code Quality Issues or PRs that relate to code quality labels May 23, 2022
@ramonjd ramonjd marked this pull request as ready for review May 23, 2022 02:02
@ramonjd ramonjd requested a review from scruffian May 23, 2022 02:02
@ramonjd
Copy link
Member Author

ramonjd commented May 23, 2022

Closing in favour of original PR
#41217

@ramonjd ramonjd closed this May 23, 2022
@ramonjd ramonjd deleted the try/get-style-nodes-optional-selector-arg branch May 23, 2022 02:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Bug An existing feature does not function as intended [Type] Code Quality Issues or PRs that relate to code quality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant