Changeset 47351
- Timestamp:
- 02/24/2020 06:05:12 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/rest-api/class-wp-rest-server.php
r47326 r47351 880 880 $path = $request->get_route(); 881 881 882 $ routes= array();882 $with_namespace = array(); 883 883 884 884 foreach ( $this->get_namespaces() as $namespace ) { 885 if ( 0 === strpos( ltrim( $path, '/' ), $namespace ) ) { 886 $routes = $this->get_routes( $namespace ); 887 break; 888 } 889 } 890 891 if ( ! $routes ) { 885 if ( 0 === strpos( trailingslashit( ltrim( $path, '/' ) ), $namespace ) ) { 886 $with_namespace[] = $this->get_routes( $namespace ); 887 } 888 } 889 890 if ( $with_namespace ) { 891 $routes = array_merge( ...$with_namespace ); 892 } else { 892 893 $routes = $this->get_routes(); 893 894 } -
trunk/tests/phpunit/tests/rest-api/rest-server.php
r47326 r47351 1466 1466 } 1467 1467 1468 /** 1469 * @ticket 48530 1470 */ 1471 public function test_get_routes_no_namespace_overriding() { 1472 register_rest_route( 1473 'test-ns', 1474 '/test', 1475 array( 1476 'methods' => array( 'GET' ), 1477 'callback' => function() { 1478 return new WP_REST_Response( 'data', 204 ); 1479 }, 1480 ) 1481 ); 1482 register_rest_route( 1483 'test-ns/v1', 1484 '/test', 1485 array( 1486 'methods' => array( 'GET' ), 1487 'callback' => function() { 1488 return new WP_REST_Response( 'data', 204 ); 1489 }, 1490 ) 1491 ); 1492 1493 $request = new WP_REST_Request( 'GET', '/test-ns/v1/test' ); 1494 $response = rest_get_server()->dispatch( $request ); 1495 1496 $this->assertEquals( 204, $response->get_status(), '/test-ns/v1/test' ); 1497 } 1498 1468 1499 public function _validate_as_integer_123( $value, $request, $key ) { 1469 1500 if ( ! is_int( $value ) ) {
Note: See TracChangeset
for help on using the changeset viewer.