Skip to content

Commit

Permalink
REST API: Correctly serve the index with PATH_INFO
Browse files Browse the repository at this point in the history
When hitting the index, untrailingslashit() would make the REST route empty, which would then use the fallback inside WP_REST_Server. This isn't a problem most of the time, but WP_REST_Server contains a fallback to PATH_INFO. Combined with PATH_INFO permalinks, this would give a 404 on the API index, as it attempts to look up a route for "/wp-json/".

Props ccprog.
Fixes #39432.


git-svn-id: https://develop.svn.wordpress.org/trunk@39923 602fd350-edb4-49c9-b593-d223f7449a82
  • Loading branch information
rmccue committed Jan 17, 2017
1 parent bbf129c commit 7d2c104
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/wp-includes/rest-api.php
Expand Up @@ -256,7 +256,11 @@ function rest_api_loaded() {
$server = rest_get_server();

// Fire off the request.
$server->serve_request( untrailingslashit( $GLOBALS['wp']->query_vars['rest_route'] ) );
$route = untrailingslashit( $GLOBALS['wp']->query_vars['rest_route'] );
if ( empty( $route ) ) {
$route = '/';
}
$server->serve_request( $route );

// We're done.
die();
Expand Down

0 comments on commit 7d2c104

Please sign in to comment.