Make WordPress Core

Changeset 39923


Ignore:
Timestamp:
01/17/2017 05:39:15 AM (8 years ago)
Author:
rmccue
Message:

REST API: Correctly serve the index with PATH_INFO

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/rest-api.php

    r39896 r39923  
    257257
    258258    // Fire off the request.
    259     $server->serve_request( untrailingslashit( $GLOBALS['wp']->query_vars['rest_route'] ) );
     259    $route = untrailingslashit( $GLOBALS['wp']->query_vars['rest_route'] );
     260    if ( empty( $route ) ) {
     261        $route = '/';
     262    }
     263    $server->serve_request( $route );
    260264
    261265    // We're done.
Note: See TracChangeset for help on using the changeset viewer.