Don't prepare the response body for HEAD requests#7970
Don't prepare the response body for HEAD requests#7970anton-vlasenko wants to merge 51 commits intoWordPress:trunkfrom
Conversation
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
ironprogrammer
left a comment
There was a problem hiding this comment.
Thanks for putting this all together, @anton-vlasenko 🙌🏻 I've got a name tweak suggestion for some of the newly added methods to consider.
| * | ||
| * @param string $method HTTP method to use. | ||
| */ | ||
| public function test_get_items_returns_only_fetches_ids_for_head_requests( $method ) { |
There was a problem hiding this comment.
| public function test_get_items_returns_only_fetches_ids_for_head_requests( $method ) { | |
| public function test_get_items_returns_only_ids_for_head_requests( $method ) { |
For this and other same-named tests in the updated test classes under this PR, returns_only_fetches has two verbs, but should only use one for clarity.
Scanning other test classes, "return" is used more extensively than "fetch", so IMHO these new methods should use returns_only_ids. What do you think?
There was a problem hiding this comment.
Well spotted, @ironprogrammer! Having two verbs here doesn't make sense. This is likely the result of extensive copy-pasting between different test classes. :)
I'm leaning towards test_get_items_fetches_only_ids_for_head_requests, because what I meant is that the get_items() method fetches only the *id* column from the database for HEAD requests, as opposed to fetching all columns for GET requests.
Fixed in 9c91e45.
| * | ||
| * @param string $method HTTP method to use. | ||
| */ | ||
| public function test_get_items_only_fetches_ids_for_head_requests( $method ) { |
There was a problem hiding this comment.
| public function test_get_items_only_fetches_ids_for_head_requests( $method ) { | |
| public function test_get_items_returns_only_ids_for_head_requests( $method ) { |
Suggestion per previous note.
| * | ||
| * @param string $method HTTP method to use. | ||
| */ | ||
| public function test_get_items_returns_only_fetches_ids_for_head_requests( $method ) { |
There was a problem hiding this comment.
| public function test_get_items_returns_only_fetches_ids_for_head_requests( $method ) { | |
| public function test_get_items_returns_only_ids_for_head_requests( $method ) { |
Suggestion per above.
| * | ||
| * @param string $method HTTP method to use. | ||
| */ | ||
| public function test_get_items_returns_only_fetches_ids_for_head_requests( $method ) { |
There was a problem hiding this comment.
| public function test_get_items_returns_only_fetches_ids_for_head_requests( $method ) { | |
| public function test_get_items_returns_only_ids_for_head_requests( $method ) { |
Suggestion per above.
| * | ||
| * @param string $method HTTP method to use. | ||
| */ | ||
| public function test_get_items_returns_only_fetches_ids_for_head_requests( $method ) { |
There was a problem hiding this comment.
| public function test_get_items_returns_only_fetches_ids_for_head_requests( $method ) { | |
| public function test_get_items_returns_only_ids_for_head_requests( $method ) { |
Suggestion per above.
Context: WordPress#7970 (comment) Props @ironprogrammer.
|
Fantastic work, @anton-vlasenko! Let me know how I can help to land this in WP 6.8. I think it would improve editors' loading performance. |
Thank you, @Mamaduka.
Thank you for offering your help! |
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Unlinked AccountsThe following contributors have not linked their GitHub and WordPress.org accounts: @jonnynews. Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases. Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
Yeah I'm planning on landing this this weekend. |
spacedmonkey
left a comment
There was a problem hiding this comment.
I think we need to also disable any meta and term cache priming as well, as this results in database queries.
Also if there are changes to be made for taxononmy endpoint, those changes should also be made for post type endpoint. Otherwise this looks like great work.
src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php
Show resolved
Hide resolved
9d1f623 to
b80fd51
Compare
Thank you for the review, @spacedmonkey. |
|
I think we have a BC issue with the single item route. Right now, if I use the I think we might want to move the |
Thank you for the review, @TimothyBJacobs.
It could theoretically happen, but I’m not aware of any such cases. That said, I also agree that GET and HEAD requests should behave similarly, with the exception that HEAD requests don’t include a response body. I’m working on a fix. |
…troller for HEAD requests.
…emplate_Revisions_Controller controllers.
|
UPD: Done. |
…ons-controller.php Don't use a PHPDoc block because it doesn't contain any PHPDoc tags. Co-authored-by: Mukesh Panchal <mukeshpanchal27@users.noreply.github.com>
8d13489 to
fd60b44
Compare
fd60b44 to
48b4c48
Compare
Trac ticket: https://core.trac.wordpress.org/ticket/56481
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.