Ticket #40704: 40704.3.diff
| File 40704.3.diff, 1.7 KB (added by , 9 years ago) |
|---|
-
src/wp-includes/rest-api/class-wp-rest-server.php
824 824 $path = $request->get_route(); 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 831 } 832 832 833 $args = array(); 834 foreach ( $matches as $param => $value ) { 835 if ( ! is_int( $param ) ) { 836 $args[ $param ] = $value; 837 } 838 } 839 833 840 foreach ( $handlers as $handler ) { 834 841 $callback = $handler['callback']; 835 842 $response = null; -
tests/phpunit/tests/rest-api/rest-server.php
163 163 } 164 164 165 165 /** 166 * @ticket 40704 167 */ 168 public function test_url_params_no_numeric_keys() { 169 170 $this->server->register_route( 'test', '/test/(?P<data>.*)', array( 171 array( 172 'methods' => WP_REST_Server::READABLE, 173 'callback' => '__return_false', 174 'args' => array( 175 'data' => array(), 176 ), 177 ), 178 ) ); 179 180 $request = new WP_REST_Request( 'GET', '/test/some-value' ); 181 $this->server->dispatch( $request ); 182 $this->assertEquals( array( 'data' => 'some-value' ), $request->get_params() ); 183 } 184 185 /** 166 186 * Pass a capability which the user does not have, this should 167 187 * result in a 403 error. 168 188 */