WordPress.org

Make WordPress Core


Ignore:
Timestamp:
10/10/2017 04:45:01 PM (3 years ago)
Author:
boonebgorges
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/taxonomy.php

    r41688 r41809  
    19131913    // Taxonomies registered without an 'args' param are handled here.
    19141914    if ( ! empty( $taxonomies ) ) {
    1915         $terms = array_merge( $terms, get_terms( $args ) );
     1915        $terms_from_remaining_taxonomies = get_terms( $args );
     1916
     1917        // Array keys should be preserved for values of $fields that use term_id for keys.
     1918        if ( ! empty( $args['fields'] ) && 0 === strpos( $args['fields'], 'id=>' ) ) {
     1919            $terms = $terms + $terms_from_remaining_taxonomies;
     1920        } else {
     1921            $terms = array_merge( $terms, $terms_from_remaining_taxonomies );
     1922        }
    19161923    }
    19171924
Note: See TracChangeset for help on using the changeset viewer.