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
This commit is contained in:
Boone Gorges 2017-10-10 16:45:48 +00:00
parent 8f4e2bdb6b
commit 8d773262f3
2 changed files with 9 additions and 2 deletions

View File

@ -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 );
}
}
/**

View File

@ -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.