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

@@ -286,6 +286,18 @@ class Tests_REST_Request extends WP_UnitTestCase {
$this->assertEquals( $expected, $this->request->get_params() );
}
public function test_parameter_merging_with_numeric_keys() {
$this->request->set_query_params( array(
'1' => 'hello',
'2' => 'goodbye',
) );
$expected = array(
'1' => 'hello',
'2' => 'goodbye',
);
$this->assertEquals( $expected, $this->request->get_params() );
}
public function test_sanitize_params() {
$this->request->set_url_params( array(
'someinteger' => '123',