REST API: Change method of merging parameters.

`array_merge()` incorrectly reindexes numeric parameters, causing things like `{"123": true}` to be "dropped".

Props sswells, joehoyle.
Fixes #38306.

Built from https://develop.svn.wordpress.org/trunk@39087


git-svn-id: http://core.svn.wordpress.org/trunk@39029 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Ryan McCue 2016-11-02 05:53:31 +00:00
parent dab566d973
commit d7bdd72510
2 changed files with 6 additions and 2 deletions

View File

@ -451,7 +451,11 @@ class WP_REST_Request implements ArrayAccess {
$params = array(); $params = array();
foreach ( $order as $type ) { foreach ( $order as $type ) {
$params = array_merge( $params, (array) $this->params[ $type ] ); // array_merge / the "+" operator will mess up
// numeric keys, so instead do a manual foreach.
foreach ( (array) $this->params[ $type ] as $key => $value ) {
$params[ $key ] = $value;
}
} }
return $params; return $params;

View File

@ -4,7 +4,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '4.7-beta1-39086'; $wp_version = '4.7-beta1-39087';
/** /**
* 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.