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

WP_REST_Pattern_Directory_Controller::get_items doesn't support array arguments #40900

Conversation

anton-vlasenko
Copy link
Contributor

@anton-vlasenko anton-vlasenko commented May 6, 2022

What?

This PR aims to backport changes from WordPress/wordpress-develop#2591 and WordPress/wordpress-develop#2625 back to Gutenberg.

Fixes #40824.

Why?

This is needed to keep Core and Gutenberg as compatible as possible.

Testing Instructions

  1. Make sure you are using WordPress 5.9.x
  2. Enable Gutenberg.
  3. Install this plugin to allow basic authorization for REST API requests.
  4. Activate the plugin.
  5. Send a GET request to your WordPress instance, e.g.:
curl --user username:user_password "http://your.wordpress.instance/wp-json/wp/v2/pattern-directory/patterns?slug=visual-navigation-with-rainbow-gradient,three-columns-of-text-with-buttons"

Replace

username:user_password

with the actual credentials.
Replace

http://your.wordpress.instance

with the actual URL of your instance.
5. Note the response. It should contain 2 patterns.
6. Send a GET request again, but this time replace the slug parameter
with some non-existent pattern. E.g.:

curl --user username:user_password "http://your.wordpress.instance/wp-json/wp/v2/pattern-directory/patterns?slug=non-existent-pattern"
  1. The endpoint should return an empty response.
  2. Repeat steps 2-7, but this time use WordPress 6.0.x (or the latest Beta/RC version if WordPress 6.0 is not released yet).

@anton-vlasenko anton-vlasenko marked this pull request as draft May 6, 2022 19:08
@anton-vlasenko anton-vlasenko added Backport from WordPress Core Pull request that needs to be backported to a Gutenberg release from WordPress Core [Type] Enhancement A suggestion for improvement. [Feature] Patterns A collection of blocks that can be synced (previously reusable blocks) or unsynced labels May 6, 2022
@anton-vlasenko anton-vlasenko marked this pull request as ready for review May 6, 2022 20:32
@anton-vlasenko anton-vlasenko changed the title Fix/pattern directory controller must allow processing array request arguments WP_REST_Pattern_Directory_Controller::get_items doesn't support array arguments May 6, 2022
@anton-vlasenko anton-vlasenko added this to the Gutenberg 13.3 milestone May 6, 2022
@spacedmonkey
Copy link
Member

Can this be closed?

@anton-vlasenko
Copy link
Contributor Author

anton-vlasenko commented May 10, 2022

@spacedmonkey

Can this be closed?

Excuse me, I'm not sure I understand why this PR should be closed.
It backports the changes from Core to Gutenberg so that the two codebases don't diverge that much.
Is there a reason not to backport these changes to Gutenberg?

@ndiego
Copy link
Member

ndiego commented Jun 29, 2022

@gziolo @Mamaduka pinging you both for an extra set of eyes. I believe we need to get this backported asap but I am not very clear on the backporting process. This is blocking a fix for #41282 that I have planned. Any help would be greatly appreciated 🙏

Copy link
Member

@Mamaduka Mamaduka left a comment

Choose a reason for hiding this comment

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

This looks good to me, and the core team has already reviewed the code.

Thanks, @anton-vlasenko.

@gziolo gziolo merged commit 547ad5c into trunk Jun 30, 2022
@gziolo gziolo deleted the fix/pattern-directory-controller-must-allow-processing-array-request-arguments branch June 30, 2022 07:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Backport from WordPress Core Pull request that needs to be backported to a Gutenberg release from WordPress Core [Feature] Patterns A collection of blocks that can be synced (previously reusable blocks) or unsynced [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Backport fixes for wp/v2/block-patterns/patterns and /wp/v2/pattern-directory/patterns endpoints to Gutenberg
5 participants