WordPress.org

Make WordPress Core

Changeset 37634


Ignore:
Timestamp:
06/04/2016 12:19:15 PM (4 years ago)
Author:
boonebgorges
Message:

Taxonomy: No, really, don't pass results of 'count' query through 'get_terms' filter.

[37623] used the wrong parameter name (count=true instead of fields=count).

For greater flexibility and forward compatibility with other potential changes
to the return value of get_terms(), we now do a looser check: any non-array
value is excluded from the filter.

Fixes #36992.

Location:
trunk
Files:
2 edited

Legend:

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

    r37623 r37634  
    12101210
    12111211    // Count queries are not filtered, for legacy reasons.
    1212     if ( $term_query->query_vars['count'] ) {
     1212    if ( ! is_array( $terms ) ) {
    12131213        return $terms;
    12141214    }
  • trunk/tests/phpunit/tests/term/getTerms.php

    r37623 r37634  
    21842184     * @ticket 35381
    21852185     */
    2186     public function test_count_should_pass_through_main_get_terms_filter() {
     2186    public function test_count_should_not_pass_through_main_get_terms_filter() {
    21872187        add_filter( 'get_terms', array( __CLASS__, 'maybe_filter_count' ) );
    21882188
    21892189        $found = get_terms( array(
    21902190            'hide_empty' => 0,
    2191             'count' => true,
     2191            'fields' => 'count',
    21922192        ) );
    21932193
Note: See TracChangeset for help on using the changeset viewer.