Changeset 41223
- Timestamp:
- 08/03/2017 07:54:56 PM (4 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/rest-api/class-wp-rest-server.php
r41162 r41223 825 825 826 826 foreach ( $this->get_routes() as $route => $handlers ) { 827 $match = preg_match( '@^' . $route . '$@i', $path, $ args );827 $match = preg_match( '@^' . $route . '$@i', $path, $matches ); 828 828 829 829 if ( ! $match ) { 830 830 continue; 831 } 832 833 $args = array(); 834 foreach ( $matches as $param => $value ) { 835 if ( ! is_int( $param ) ) { 836 $args[ $param ] = $value; 837 } 831 838 } 832 839 -
trunk/tests/phpunit/tests/rest-api/rest-server.php
r40805 r41223 161 161 $response = $this->server->dispatch( $request ); 162 162 $this->assertEquals( 200, $response->get_status() ); 163 } 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() ); 163 180 } 164 181
Note: See TracChangeset
for help on using the changeset viewer.