mirror of
https://github.com/WordPress/WordPress.git
synced 2024-10-01 08:37:55 +02:00
REST API: Fix namespace shadowing issue in route matching logic.
Following [47260] a namespace such as "test-ns" prevents any namespace such as "test-ns/v1" from being found when matching routes. While not best practice, this was an unintentional back-compat break; this patch restores the original behavior. Props david.binda, TimothyBlynJacobs. Fixes #48530. Built from https://develop.svn.wordpress.org/trunk@47351 git-svn-id: http://core.svn.wordpress.org/trunk@47138 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
4aeebf03a5
commit
480372b07c
@ -879,16 +879,17 @@ class WP_REST_Server {
|
|||||||
$method = $request->get_method();
|
$method = $request->get_method();
|
||||||
$path = $request->get_route();
|
$path = $request->get_route();
|
||||||
|
|
||||||
$routes = array();
|
$with_namespace = array();
|
||||||
|
|
||||||
foreach ( $this->get_namespaces() as $namespace ) {
|
foreach ( $this->get_namespaces() as $namespace ) {
|
||||||
if ( 0 === strpos( ltrim( $path, '/' ), $namespace ) ) {
|
if ( 0 === strpos( trailingslashit( ltrim( $path, '/' ) ), $namespace ) ) {
|
||||||
$routes = $this->get_routes( $namespace );
|
$with_namespace[] = $this->get_routes( $namespace );
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! $routes ) {
|
if ( $with_namespace ) {
|
||||||
|
$routes = array_merge( ...$with_namespace );
|
||||||
|
} else {
|
||||||
$routes = $this->get_routes();
|
$routes = $this->get_routes();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '5.4-beta2-47350';
|
$wp_version = '5.4-beta2-47351';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
Loading…
Reference in New Issue
Block a user