Make WordPress Core


Ignore:
Timestamp:
11/02/2016 05:52:12 AM (8 years ago)
Author:
rmccue
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/rest-api/rest-request.php

    r38601 r39087  
    283283            'has_body_params'    => true,
    284284            'has_default_params' => true,
     285        );
     286        $this->assertEquals( $expected, $this->request->get_params() );
     287    }
     288
     289    public function test_parameter_merging_with_numeric_keys() {
     290        $this->request->set_query_params( array(
     291            '1'           => 'hello',
     292            '2'           => 'goodbye',
     293        ) );
     294        $expected = array(
     295            '1'           => 'hello',
     296            '2'           => 'goodbye',
    285297        );
    286298        $this->assertEquals( $expected, $this->request->get_params() );
Note: See TracChangeset for help on using the changeset viewer.