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

Props kadamwhite, TimothyBlynJacobs.
Fixes #48266.

Built from https://develop.svn.wordpress.org/trunk@46456


git-svn-id: http://core.svn.wordpress.org/trunk@46254 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
K. Adam White 2019-10-10 17:18:03 +00:00
parent c6d3987b08
commit 1a8aba96e7
2 changed files with 7 additions and 3 deletions

View File

@ -743,8 +743,12 @@ function rest_filter_response_fields( $response, $server, $request ) {
$parts = explode( '.', $field );
$ref = &$fields_as_keyed;
while ( count( $parts ) > 1 ) {
$next = array_shift( $parts );
$ref[ $next ] = array();
$next = array_shift( $parts );
if ( isset( $ref[ $next ] ) && true === $ref[ $next ] ) {
// Skip any sub-properties if their parent prop is already marked for inclusion.
break 2;
}
$ref[ $next ] = isset( $ref[ $next ] ) ? $ref[ $next ] : array();
$ref = &$ref[ $next ];
}
$last = array_shift( $parts );

View File

@ -13,7 +13,7 @@
*
* @global string $wp_version
*/
$wp_version = '5.3-beta3-46455';
$wp_version = '5.3-beta3-46456';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.