[wp-trac] [WordPress Trac] #57455: respond_to_request: store matched handlers across other methods, saving a call to get_routes().

WordPress Trac noreply at wordpress.org
Thu Jan 12 21:53:14 UTC 2023


#57455: respond_to_request: store matched handlers across other methods, saving a
call to get_routes().
-------------------------+------------------------------
 Reporter:  mreishus     |       Owner:  (none)
     Type:  enhancement  |      Status:  new
 Priority:  normal       |   Milestone:  Awaiting Review
Component:  REST API     |     Version:
 Severity:  normal       |  Resolution:
 Keywords:               |     Focuses:
-------------------------+------------------------------

Comment (by mreishus):

 For the alternative approach: #39473 adds a per-request cache to
 get_routes: I don't know how to resolve the caching behavior with the new
 `$namespace` parameter added to `get_routes()`.

 In my example request of GET http://localhost:8889/wp-json/wp/v2/posts,
 the two calls to `get_routes()` have different parameters, since only one
 of the two applies a namespace optimization:

 * `WP_REST_Server::match_request_to_handler()` ->
 `WP_REST_Server::get_routes( 'wp_v2' )`
 * `rest_send_allow_header()` -> `WP_REST_Server::get_routes( '' )`

 A straight forward cache of $namespace -> built $endpoints wouldn't work
 without other changes.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/57455#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list