Make WordPress Core


Ignore:
Timestamp:
07/13/2017 01:42:44 PM (7 years ago)
Author:
boonebgorges
Message:

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.

Ports [41037] to the 4.8 branch.

Props bor0, atanasangelovdev.
Fixes #41010.

Location:
branches/4.8
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/4.8

  • branches/4.8/src/wp-includes/taxonomy.php

    r40513 r41038  
    18651865    $args['object_ids'] = $object_ids;
    18661866
    1867     $terms = array_merge( $terms, get_terms( $args ) );
     1867    // Taxonomies registered without an 'args' param are handled here.
     1868    if ( ! empty( $taxonomies ) ) {
     1869        $terms = array_merge( $terms, get_terms( $args ) );
     1870    }
    18681871
    18691872    /**
Note: See TracChangeset for help on using the changeset viewer.