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.


git-svn-id: https://develop.svn.wordpress.org/trunk@39087 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Ryan McCue
2016-11-02 05:52:12 +00:00
parent 5af14c3e07
commit 5d924daeb3
2 changed files with 17 additions and 1 deletions

View File

@@ -451,7 +451,11 @@ class WP_REST_Request implements ArrayAccess {
$params = array();
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;