Make WordPress Core

Changeset 25933


Ignore:
Timestamp:
10/26/2013 03:03:10 PM (11 years ago)
Author:
nacin
Message:

Fix the exclude_tree argument in get_terms(), which fixes the exclude argument in wp_list_categories().

This was a 3.7 regression caused by [25162].

props dd32.
see #25710 for trunk.

Location:
trunk
Files:
2 edited

Legend:

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

    r25596 r25933  
    13631363    if ( ! empty( $exclude_tree ) ) {
    13641364        $exclude_tree = wp_parse_id_list( $exclude_tree );
    1365         $excluded_children = array();
     1365        $excluded_children = $exclude_tree;
    13661366        foreach ( $exclude_tree as $extrunk ) {
    13671367            $excluded_children = array_merge(
  • trunk/tests/phpunit/tests/term/getTerms.php

    r25384 r25933  
    153153
    154154    /**
     155     * @ticket 25710
     156     */
     157    function test_get_terms_exclude_tree() {
     158
     159        $term_id_uncategorized = get_option( 'default_category' );
     160
     161        $term_id1 = $this->factory->category->create();
     162        $term_id11 = $this->factory->category->create( array( 'parent' => $term_id1 ) );
     163        $term_id2 = $this->factory->category->create();
     164        $term_id22 = $this->factory->category->create( array( 'parent' => $term_id2 ) );
     165
     166        // There's something else broken in the cache cleaning routines that leads to this having to be done manually
     167        delete_option( 'category_children' );
     168
     169        $terms = get_terms( 'category', array(
     170            'exclude' => $term_id_uncategorized,
     171            'fields' => 'ids',
     172            'hide_empty' => false,
     173        ) );
     174        $this->assertEquals( array( $term_id1, $term_id11, $term_id2, $term_id22 ), $terms );
     175
     176        $terms = get_terms( 'category', array(
     177            'fields' => 'ids',
     178            'exclude_tree' => "$term_id1,$term_id_uncategorized",
     179            'hide_empty' => false,
     180        ) );
     181
     182        $this->assertEquals( array( $term_id2, $term_id22 ), $terms );
     183
     184    }
     185
     186    /**
    155187     * @ticket 13992
    156188     */
Note: See TracChangeset for help on using the changeset viewer.