From 1326d9e2c7edb05fbd8462a56c44b9a51d50e2df Mon Sep 17 00:00:00 2001 From: Ryan McCue Date: Tue, 17 Jan 2017 05:40:40 +0000 Subject: [PATCH] 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. Built from https://develop.svn.wordpress.org/trunk@39923 git-svn-id: http://core.svn.wordpress.org/trunk@39860 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/rest-api.php | 6 +++++- wp-includes/version.php | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/wp-includes/rest-api.php b/wp-includes/rest-api.php index ad9bf62b2e..980f4c72a3 100644 --- a/wp-includes/rest-api.php +++ b/wp-includes/rest-api.php @@ -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(); diff --git a/wp-includes/version.php b/wp-includes/version.php index 6a0d0539ef..5a29929e1d 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.8-alpha-39922'; +$wp_version = '4.8-alpha-39923'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.