Make WordPress Core


Ignore:
Timestamp:
02/19/2017 03:27:13 AM (8 years ago)
Author:
rachelbaker
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.
Merges [39923] to the 4.7 branch.
Fixes #39432.

Location:
branches/4.7
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/4.7

  • branches/4.7/src/wp-includes/rest-api.php

    r39957 r40079  
    265265
    266266    // Fire off the request.
    267     $server->serve_request( untrailingslashit( $GLOBALS['wp']->query_vars['rest_route'] ) );
     267    $route = untrailingslashit( $GLOBALS['wp']->query_vars['rest_route'] );
     268    if ( empty( $route ) ) {
     269        $route = '/';
     270    }
     271    $server->serve_request( $route );
    268272
    269273    // We're done.
Note: See TracChangeset for help on using the changeset viewer.