[wp-trac] [WordPress Trac] #39727: REST API: Add $last_request property to WP_REST_Server as per Spy_REST_Server.
WordPress Trac
noreply at wordpress.org
Sat Jan 28 08:45:58 UTC 2017
#39727: REST API: Add $last_request property to WP_REST_Server as per
Spy_REST_Server.
--------------------------+-----------------------------
Reporter: rheinardkorf | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: General | Version: 4.7.2
Severity: normal | Keywords:
Focuses: |
--------------------------+-----------------------------
There are a number of times that $_GET is required to retrieve parameters.
Within `WP_REST_Server::serve_request()` the following code sets up a
request object:
{{{#!php
$request = new WP_REST_Request( $_SERVER['REQUEST_METHOD'], $path );
$request->set_query_params( wp_unslash( $_GET ) );
$request->set_body_params( wp_unslash( $_POST ) );
}}}
If this request could be added to a `last_request` property then
parameters can be retrieved by code like
`$this->last_request->get_query_params()`. This eliminates the need to
retrieve values using $_GET and also makes Unit Tests a lot nicer.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/39727>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list