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/v2/pattern-directory/patterns endpoint: slug parameter has no effect on the response #2625

Conversation

anton-vlasenko
Copy link

Trac ticket: https://core.trac.wordpress.org/ticket/55617


This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

Strings will be automatically converted to an array.
Per suggestion here: WordPress#2625 (comment)
…nsient_key method as it would be helpful to make it available to child classes.
@spacedmonkey spacedmonkey self-requested a review April 27, 2022 13:29
}
}

return 'wp_remote_block_patterns_' . md5( implode( '-', $query_args ) );
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
return 'wp_remote_block_patterns_' . md5( implode( '-', $query_args ) );
return 'wp_remote_block_patterns_' . md5( serialize( $query_args ) );

Copy link
Author

@anton-vlasenko anton-vlasenko Apr 27, 2022

Choose a reason for hiding this comment

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

Yes, I've been thinking about replacing implode with wp_json_encode (json_encode is faster than serialize) in the scope of another PR, but serialize will do too.
The result produced by implode doesn't depend on the keys of the $query_args array. Therefore, this increases the chance of collisions.
Fixed in 2c08eea
P.S. I didn't change it because I was afraid that it would cause a sharp increase in the number of requests to the wp/v2/pattern-directory/patterns endpoint once WordPress 6.0 is released. The old values stored in the cache will be invalidated because this PR replaces implode with serialize.
I hope it will not happen since not all WordPress sites are updated simultaneously.

Copy link
Member

@spacedmonkey spacedmonkey left a comment

Choose a reason for hiding this comment

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

There are a number of changes required here.

Use WP_REST_Pattern_Directory_Controller_Test::setUp to set up the controller.
It seems there is some issue with the ::setUp method.
@anton-vlasenko
Copy link
Author

There are a number of changes required here.

Thank you for the review, @spacedmonkey!
I've replied to all code review comments.
I'd appreciate the second round of the review.

Copy link
Member

@spacedmonkey spacedmonkey left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@costdev costdev left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@ndiego
Copy link
Member

ndiego commented May 2, 2022

@anton-vlasenko I'm working on cleaning up the 6.0 Project Board. Are we waiting on anything else for this PR?

@anton-vlasenko
Copy link
Author

@anton-vlasenko I'm working on cleaning up the 6.0 Project Board. Are we waiting on anything else for this PR?

@ndiego
From a technical point of view, this PR is ready to be merged.
2 core commiters have approved it.

I don't know if there are any problems from an organizational point of view.
I'd be grateful if you could please merge it (I don't know if you have the permission to merge to Beta 4).
Thank you.

cc @peterwilsoncc

Copy link
Contributor

@hellofromtonya hellofromtonya left a comment

Choose a reason for hiding this comment

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

Ready for commit.

@hellofromtonya
Copy link
Contributor

Committed via changeset https://core.trac.wordpress.org/changeset/53333.

anton-vlasenko added a commit to WordPress/gutenberg that referenced this pull request May 5, 2022
gziolo pushed a commit to WordPress/gutenberg that referenced this pull request Jun 30, 2022
…ay arguments (#40900)

* Backport WordPress/wordpress-develop#2591 to Gutenberg.

* Backport WordPress/wordpress-develop#2625 to Gutenberg.

* Update PHPDoc block.

* Fix comments

* Replace WP with WordPress.
@WordPress WordPress deleted a comment Apr 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Archived in project
Development

Successfully merging this pull request may close these issues.

6 participants