From 8d773262f37f2d8f451b6e7ff6fe423c9273de10 Mon Sep 17 00:00:00 2001 From: Boone Gorges Date: Tue, 10 Oct 2017 16:45:48 +0000 Subject: [PATCH] Taxonomy: Don't discard keys when merging queried terms from different taxonomies. For values of `fields` like `id=>parent`, the keys of the array must be maintained as part of the query results. Introduced as part of #40496. See [38667], [40513]. Props miyauchi, dany2217, pcarvalho. Fixes #41293. Built from https://develop.svn.wordpress.org/trunk@41809 git-svn-id: http://core.svn.wordpress.org/trunk@41643 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/taxonomy.php | 9 ++++++++- wp-includes/version.php | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/wp-includes/taxonomy.php b/wp-includes/taxonomy.php index f2db5d81df..6313641d14 100644 --- a/wp-includes/taxonomy.php +++ b/wp-includes/taxonomy.php @@ -1912,7 +1912,14 @@ function wp_get_object_terms($object_ids, $taxonomies, $args = array()) { // Taxonomies registered without an 'args' param are handled here. if ( ! empty( $taxonomies ) ) { - $terms = array_merge( $terms, get_terms( $args ) ); + $terms_from_remaining_taxonomies = get_terms( $args ); + + // Array keys should be preserved for values of $fields that use term_id for keys. + if ( ! empty( $args['fields'] ) && 0 === strpos( $args['fields'], 'id=>' ) ) { + $terms = $terms + $terms_from_remaining_taxonomies; + } else { + $terms = array_merge( $terms, $terms_from_remaining_taxonomies ); + } } /** diff --git a/wp-includes/version.php b/wp-includes/version.php index a08a164ba7..bd28f198fc 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.9-beta1-41808'; +$wp_version = '4.9-beta1-41809'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.