Make WordPress Core

Ticket #32144: 32144.diff

File 32144.diff, 2.0 KB (added by boonebgorges, 10 years ago)
  • src/wp-includes/taxonomy.php

    diff --git src/wp-includes/taxonomy.php src/wp-includes/taxonomy.php
    index 7ce4093..619eb57 100644
    function _get_term_hierarchy($taxonomy) { 
    39263926 * @param string $taxonomy  The taxonomy which determines the hierarchy of the terms.
    39273927 * @param array  $ancestors Term ancestors that have already been identified. Passed by reference, to keep track of
    39283928 *                          found terms when recursing the hierarchy. The array of located ancestors is used to prevent
    3929  *                          infinite recursion loops.
     3929 *                          infinite recursion loops. For performance, term_ids are used as array keys, with 1 as value.
    39303930 * @return array The subset of $terms that are descendants of $term_id.
    39313931 */
    39323932function _get_term_children( $term_id, $terms, $taxonomy, &$ancestors = array() ) {
    function _get_term_children( $term_id, $terms, $taxonomy, &$ancestors = array() 
    39423942
    39433943        // Include the term itself in the ancestors array, so we can properly detect when a loop has occurred.
    39443944        if ( empty( $ancestors ) ) {
    3945                 $ancestors[] = $term_id;
     3945                $ancestors[ $term_id ] = 1;
    39463946        }
    39473947
    39483948        foreach ( (array) $terms as $term ) {
    function _get_term_children( $term_id, $terms, $taxonomy, &$ancestors = array() 
    39553955                }
    39563956
    39573957                // Don't recurse if we've already identified the term as a child - this indicates a loop.
    3958                 if ( in_array( $term->term_id, $ancestors ) ) {
     3958                if ( isset( $ancestors[ $term->term_id ] ) ) {
    39593959                        continue;
    39603960                }
    39613961
    function _get_term_children( $term_id, $terms, $taxonomy, &$ancestors = array() 
    39683968                        if ( !isset($has_children[$term->term_id]) )
    39693969                                continue;
    39703970
    3971                         if ( $use_id ) {
    3972                                 $ancestors = array_merge( $ancestors, $term_list );
    3973                         } else {
    3974                                 $ancestors = array_merge( $ancestors, wp_list_pluck( $term_list, 'term_id' ) );
    3975                         }
     3971                        $ancestors[ $term->term_id ] = 1;;
    39763972
    39773973                        if ( $children = _get_term_children( $term->term_id, $terms, $taxonomy, $ancestors) )
    39783974                                $term_list = array_merge($term_list, $children);