In get_terms(), select term taxonomy count for all values of 'fields'.

Not having the count caused queries with 'fields' values of 'id=>name' and
'id=>slug' to return incorrect results when querying a hierarchical taxonomy
with 'hide_empty=true'.

Includes unit tests for get_terms() when using various combinations of 'fields',
'hide_empty', and 'hierarchical' arguments.

Props technical_mastermind.
Fixes #29859.
Built from https://develop.svn.wordpress.org/trunk@29845


git-svn-id: http://core.svn.wordpress.org/trunk@29608 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Boone Gorges 2014-10-06 22:05:18 +00:00
parent 8ec2d2a151
commit 0c64fe335a

View File

@ -1512,10 +1512,10 @@ function get_terms( $taxonomies, $args = '' ) {
$selects = array( 'COUNT(*)' );
break;
case 'id=>name':
$selects = array( 't.term_id', 't.name' );
$selects = array( 't.term_id', 't.name', 'tt.count' );
break;
case 'id=>slug':
$selects = array( 't.term_id', 't.slug' );
$selects = array( 't.term_id', 't.slug', 'tt.count' );
break;
}