WordPress.org

Make WordPress Core


Ignore:
Timestamp:
10/10/2019 05:16:44 PM (2 months ago)
Author:
kadamwhite
Message:

REST API: Fix error in _fields filtering logic where only one of several requested sibling properties would be included.

Props kadamwhite, TimothyBlynJacobs.
Fixes #48266.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/rest-api.php

    r46272 r46456  
    744744        $ref   = &$fields_as_keyed;
    745745        while ( count( $parts ) > 1 ) {
    746             $next         = array_shift( $parts );
    747             $ref[ $next ] = array();
     746            $next = array_shift( $parts );
     747            if ( isset( $ref[ $next ] ) && true === $ref[ $next ] ) {
     748                // Skip any sub-properties if their parent prop is already marked for inclusion.
     749                break 2;
     750            }
     751            $ref[ $next ] = isset( $ref[ $next ] ) ? $ref[ $next ] : array();
    748752            $ref          = &$ref[ $next ];
    749753        }
Note: See TracChangeset for help on using the changeset viewer.