From a77ffd8e8396b5d777630ff6a55ad4836bdb6764 Mon Sep 17 00:00:00 2001 From: Boone Gorges Date: Sat, 4 Jun 2016 12:19:15 +0000 Subject: [PATCH] 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. git-svn-id: https://develop.svn.wordpress.org/trunk@37634 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/taxonomy.php | 2 +- tests/phpunit/tests/term/getTerms.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/wp-includes/taxonomy.php b/src/wp-includes/taxonomy.php index 534a9de4f1..47633d1f02 100644 --- a/src/wp-includes/taxonomy.php +++ b/src/wp-includes/taxonomy.php @@ -1209,7 +1209,7 @@ function get_terms( $args = array(), $deprecated = '' ) { $terms = $term_query->query( $args ); // Count queries are not filtered, for legacy reasons. - if ( $term_query->query_vars['count'] ) { + if ( ! is_array( $terms ) ) { return $terms; } diff --git a/tests/phpunit/tests/term/getTerms.php b/tests/phpunit/tests/term/getTerms.php index 623a36cb86..b12877689c 100644 --- a/tests/phpunit/tests/term/getTerms.php +++ b/tests/phpunit/tests/term/getTerms.php @@ -2183,12 +2183,12 @@ class Tests_Term_getTerms extends WP_UnitTestCase { * @ticket 36992 * @ticket 35381 */ - public function test_count_should_pass_through_main_get_terms_filter() { + public function test_count_should_not_pass_through_main_get_terms_filter() { add_filter( 'get_terms', array( __CLASS__, 'maybe_filter_count' ) ); $found = get_terms( array( 'hide_empty' => 0, - 'count' => true, + 'fields' => 'count', ) ); remove_filter( 'get_terms', array( __CLASS__, 'maybe_filter_count' ) );