Don't order term count queries.

git-svn-id: https://develop.svn.wordpress.org/trunk@14563 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Ryan Boren 2010-05-11 16:50:25 +00:00
parent 7be65b3730
commit 0adf04d6db
1 changed files with 10 additions and 1 deletions

View File

@ -819,11 +819,18 @@ function &get_terms($taxonomies, $args = '') {
$orderby = 't.slug';
else if ( 'term_group' == $_orderby )
$orderby = 't.term_group';
else if ( 'none' == $_orderby )
$orderby = '';
elseif ( empty($_orderby) || 'id' == $_orderby )
$orderby = 't.term_id';
$orderby = apply_filters( 'get_terms_orderby', $orderby, $args );
if ( !empty($orderby) )
$orderby = "ORDER BY $orderby";
else
$order = '';
$where = '';
$inclusions = '';
if ( !empty($include) ) {
@ -916,11 +923,13 @@ function &get_terms($taxonomies, $args = '') {
$selects = array('t.term_id', 'tt.parent', 'tt.count', 't.name');
break;
case 'count':
$orderby = '';
$order = '';
$selects = array('COUNT(*)');
}
$select_this = implode(', ', apply_filters( 'get_terms_fields', $selects, $args ));
$query = "SELECT $select_this FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy IN ($in_taxonomies) $where ORDER BY $orderby $order $limit";
$query = "SELECT $select_this FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy IN ($in_taxonomies) $where $orderby $order $limit";
if ( 'count' == $fields ) {
$term_count = $wpdb->get_var($query);