mirror of
https://github.com/WordPress/WordPress.git
synced 2025-01-09 18:08:09 +01:00
REST API: Fix changing parameters with set_param()
for some requests.
Prior to this commit, `WP_Rest_Request::get_param()` traversed through the parameter order but `WP_Rest_Request::set_param()` did not. For JSON requests (and likely other situations as well), this meant that changing a parameter with `set_param()` would have no effect on `get_param()`. Props TimothyBlynJacobs. Fixes #40344. Built from https://develop.svn.wordpress.org/trunk@40815 git-svn-id: http://core.svn.wordpress.org/trunk@40673 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
24a7666e69
commit
252ab08d88
@ -354,7 +354,11 @@ class WP_REST_Request implements ArrayAccess {
|
|||||||
*/
|
*/
|
||||||
protected function get_parameter_order() {
|
protected function get_parameter_order() {
|
||||||
$order = array();
|
$order = array();
|
||||||
|
|
||||||
|
$content_type = $this->get_content_type();
|
||||||
|
if ( $content_type['value'] === 'application/json' ) {
|
||||||
$order[] = 'JSON';
|
$order[] = 'JSON';
|
||||||
|
}
|
||||||
|
|
||||||
$this->parse_json_params();
|
$this->parse_json_params();
|
||||||
|
|
||||||
@ -424,15 +428,8 @@ class WP_REST_Request implements ArrayAccess {
|
|||||||
* @param mixed $value Parameter value.
|
* @param mixed $value Parameter value.
|
||||||
*/
|
*/
|
||||||
public function set_param( $key, $value ) {
|
public function set_param( $key, $value ) {
|
||||||
switch ( $this->method ) {
|
$order = $this->get_parameter_order();
|
||||||
case 'POST':
|
$this->params[ $order[0] ][ $key ] = $value;
|
||||||
$this->params['POST'][ $key ] = $value;
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
$this->params['GET'][ $key ] = $value;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '4.8-beta1-40814';
|
$wp_version = '4.8-beta1-40815';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
Loading…
Reference in New Issue
Block a user