Taxonomy: Avoid duplicates when querying for terms in taxonomies registered with `$args` parameter.

[40514] introduced a bug that caused term queries to return some duplicates
when the `$taxonomies` array contained only taxonomies that were originally
registered with an `$args` array. We fix this bug by ensuring that
recursive `get_terms()` queries stop when all queried `$taxonomies` have
already been referenced.

Props bor0, atanasangelovdev.
Fixes #41010.
Built from https://develop.svn.wordpress.org/trunk@41037


git-svn-id: http://core.svn.wordpress.org/trunk@40887 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Boone Gorges 2017-07-13 13:41:44 +00:00
parent 3b9e61cdb1
commit 65e2935636
2 changed files with 5 additions and 2 deletions

View File

@ -1917,7 +1917,10 @@ function wp_get_object_terms($object_ids, $taxonomies, $args = array()) {
$args['taxonomy'] = $taxonomies; $args['taxonomy'] = $taxonomies;
$args['object_ids'] = $object_ids; $args['object_ids'] = $object_ids;
$terms = array_merge( $terms, get_terms( $args ) ); // Taxonomies registered without an 'args' param are handled here.
if ( ! empty( $taxonomies ) ) {
$terms = array_merge( $terms, get_terms( $args ) );
}
/** /**
* Filters the terms for a given object or objects. * Filters the terms for a given object or objects.

View File

@ -4,7 +4,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '4.9-alpha-41036'; $wp_version = '4.9-alpha-41037';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.