REST API: Accept string path in rest_ensure_request.

Update `rest_ensure_request()` to accept a string path, permitting a string path to be passed to `rest_do_request()` as is indicated (previously inaccurately) in that method's PHPDoc.

Props TimothyBlynJacobs, kadamwhite.
Fixes #40614.

Built from https://develop.svn.wordpress.org/trunk@46099


git-svn-id: http://core.svn.wordpress.org/trunk@45911 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
K. Adam White 2019-09-12 21:47:57 +00:00
parent 742ab2d68b
commit c148f0aa55
2 changed files with 7 additions and 2 deletions

View File

@ -482,8 +482,9 @@ function rest_get_server() {
* Ensures request arguments are a request object (for consistency).
*
* @since 4.4.0
* @since 5.3.0 Accept string argument for the request path.
*
* @param array|WP_REST_Request $request Request to check.
* @param array|string|WP_REST_Request $request Request to check.
* @return WP_REST_Request REST request instance.
*/
function rest_ensure_request( $request ) {
@ -491,6 +492,10 @@ function rest_ensure_request( $request ) {
return $request;
}
if ( is_string( $request ) ) {
return new WP_REST_Request( 'GET', $request );
}
return new WP_REST_Request( 'GET', '', $request );
}

View File

@ -13,7 +13,7 @@
*
* @global string $wp_version
*/
$wp_version = '5.3-alpha-46098';
$wp_version = '5.3-alpha-46099';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.