From 1a8aba96e7a8d7538156af71ad9742f4d1a98075 Mon Sep 17 00:00:00 2001 From: "K. Adam White" Date: Thu, 10 Oct 2019 17:18:03 +0000 Subject: [PATCH] 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 --- wp-includes/rest-api.php | 8 ++++++-- wp-includes/version.php | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/wp-includes/rest-api.php b/wp-includes/rest-api.php index c397bdc116..3e6f419f6b 100644 --- a/wp-includes/rest-api.php +++ b/wp-includes/rest-api.php @@ -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 ); diff --git a/wp-includes/version.php b/wp-includes/version.php index e0d4c09220..6790ff9d48 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -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.