REST API: Remove redundant "0" parameter.
This is just an artifact of how we parse the URL, and is already available via $request->get_route() Props danielbachhuber. Fixes #34647. git-svn-id: https://develop.svn.wordpress.org/trunk@35659 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
7b12240b12
commit
52bdf9d6a5
@ -789,6 +789,8 @@ class WP_REST_Server {
|
||||
}
|
||||
|
||||
if ( ! is_wp_error( $response ) ) {
|
||||
// Remove the redundant preg_match argument.
|
||||
unset( $args[0] );
|
||||
|
||||
$request->set_url_params( $args );
|
||||
$request->set_attributes( $handler );
|
||||
|
@ -106,6 +106,21 @@ class Tests_REST_Server extends WP_Test_REST_TestCase {
|
||||
$this->assertArrayNotHasKey( 'foo', (array) $request );
|
||||
}
|
||||
|
||||
public function test_no_zero_param() {
|
||||
register_rest_route( 'no-zero', '/test', array(
|
||||
'methods' => array( 'GET' ),
|
||||
'callback' => '__return_null',
|
||||
'args' => array(
|
||||
'foo' => array(
|
||||
'default' => 'bar',
|
||||
),
|
||||
),
|
||||
) );
|
||||
$request = new WP_REST_Request( 'GET', '/no-zero/test' );
|
||||
$this->server->dispatch( $request );
|
||||
$this->assertEquals( array( 'foo' => 'bar' ), $request->get_params() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Pass a capability which the user does not have, this should
|
||||
* result in a 403 error.
|
||||
|
Loading…
Reference in New Issue
Block a user