diff --git a/src/wp-includes/rest-api/class-wp-rest-server.php b/src/wp-includes/rest-api/class-wp-rest-server.php
index 2ec8ccd..e004844 100644
|
a
|
b
|
class WP_REST_Server { |
| 842 | 842 | $path = $request->get_route(); |
| 843 | 843 | |
| 844 | 844 | foreach ( $this->get_routes() as $route => $handlers ) { |
| 845 | | $match = preg_match( '@^' . $route . '$@i', $path, $args ); |
| | 845 | $match = preg_match( '@^' . $route . '$@i', $path, $matches ); |
| 846 | 846 | |
| 847 | 847 | if ( ! $match ) { |
| 848 | 848 | continue; |
| 849 | 849 | } |
| 850 | 850 | |
| | 851 | $args = array(); |
| | 852 | foreach ( $matches as $param => $value ) { |
| | 853 | if ( ! is_int( $param ) ) { |
| | 854 | $args[ $param ] = $value; |
| | 855 | } |
| | 856 | } |
| | 857 | |
| 851 | 858 | foreach ( $handlers as $handler ) { |
| 852 | 859 | $callback = $handler['callback']; |
| 853 | 860 | $response = null; |
diff --git a/tests/phpunit/tests/rest-api/rest-server.php b/tests/phpunit/tests/rest-api/rest-server.php
index 1cd9e68..cb75f4e 100644
|
a
|
b
|
class Tests_REST_Server extends WP_Test_REST_TestCase { |
| 162 | 162 | $this->assertEquals( 200, $response->get_status() ); |
| 163 | 163 | } |
| 164 | 164 | |
| | 165 | public function test_url_params_no_numeric_keys() { |
| | 166 | |
| | 167 | $this->server->register_route( 'test', '/test/(?P<data>.*)', array( |
| | 168 | array( |
| | 169 | 'methods' => WP_REST_Server::READABLE, |
| | 170 | 'callback' => '__return_false', |
| | 171 | 'args' => array( |
| | 172 | 'data' => array(), |
| | 173 | ), |
| | 174 | ), |
| | 175 | ) ); |
| | 176 | |
| | 177 | $request = new WP_REST_Request( 'GET', '/test/some-value' ); |
| | 178 | $this->server->dispatch( $request ); |
| | 179 | $this->assertEquals( array( 'data' => 'some-value' ), $request->get_params() ); |
| | 180 | } |
| | 181 | |
| 165 | 182 | /** |
| 166 | 183 | * Pass a capability which the user does not have, this should |
| 167 | 184 | * result in a 403 error. |