[wp-trac] [WordPress Trac] #40344: WP_REST_Request::set_param() ignores parameter order.
WordPress Trac
noreply at wordpress.org
Mon Apr 3 01:27:41 UTC 2017
#40344: WP_REST_Request::set_param() ignores parameter order.
-------------------------------+-----------------------------
Reporter: TimothyBlynJacobs | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: REST API | Version: trunk
Severity: normal | Keywords:
Focuses: rest-api |
-------------------------------+-----------------------------
`WP_Rest_Request::get_param()` traverses through the parameter order but
`WP_Rest_Request::set_param()` does not. For JSON requests, this means
that changing a parameter with `set_param()` will have no affect on
`get_param()`.
Example Code:
{{{
$request = new WP_REST_Request();
$request->add_header( 'content-type', 'application/json' );
$request->set_method( 'POST' );
$request->set_body( wp_json_encode( [
'param' => 'hi'
] ) );
echo $request->get_param( 'param' ); // hi
$request->set_param( 'param', 'hello' );
echo $request->get_param( 'param' ); // hi
}}}
Patch incoming.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/40344>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list