Make WordPress Core


Ignore:
Timestamp:
11/02/2016 05:52:12 AM (9 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/src/wp-includes/rest-api/class-wp-rest-request.php

    r39027 r39087  
    452452        $params = array();
    453453        foreach ( $order as $type ) {
    454             $params = array_merge( $params, (array) $this->params[ $type ] );
     454            // array_merge / the "+" operator will mess up
     455            // numeric keys, so instead do a manual foreach.
     456            foreach ( (array) $this->params[ $type ] as $key => $value ) {
     457                $params[ $key ] = $value;
     458            }
    455459        }
    456460
Note: See TracChangeset for help on using the changeset viewer.