[wp-trac] [WordPress Trac] #56481: Short-circuit HEAD methods in Core controllers
WordPress Trac
noreply at wordpress.org
Fri Sep 13 13:56:08 UTC 2024
#56481: Short-circuit HEAD methods in Core controllers
--------------------------------------+------------------------------------
Reporter: TimothyBlynJacobs | Owner: (none)
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: REST API | Version: 4.7
Severity: normal | Resolution:
Keywords: has-patch has-unit-tests | Focuses: rest-api, performance
--------------------------------------+------------------------------------
Changes (by antonvlasenko):
* focuses: performance => rest-api, performance
Comment:
I've just submitted a first PR to address the issue for the
WP_REST_Posts_Controller controller: https://github.com/WordPress
/wordpress-develop/pull/7349.
> I think we'd want to extract the pagination logic to it's own method.
For the `WP_REST_Posts_Controller`, the adjustments required for `HEAD`
requests compared to standard `GET` requests are minimal, so I found it
unnecessary to extract the pagination logic into a separate method.
As suggested by @TimothyBlynJacobs, the proposed PR optimizes performance
by adjusting the query to return only ids. If the direction of my PR is
considered correct, I am prepared to make similar adjustments for other
controllers in future PRs.
My PR also adds several unit tests for the HEAD method to ensure that the
`WP_REST_Posts_Controller` functions correctly.
Please note that I will be unavailable until Sep 23, but I can resume work
on subsequent PRs upon my return.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/56481#comment:5>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list