From 98b2e56753046ce352ec7b6672a301bf597f24fc Mon Sep 17 00:00:00 2001 From: ryan Date: Tue, 11 May 2010 16:50:25 +0000 Subject: [PATCH] Don't order term count queries. git-svn-id: http://svn.automattic.com/wordpress/trunk@14563 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/taxonomy.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/wp-includes/taxonomy.php b/wp-includes/taxonomy.php index 9806106ec..72cf57495 100644 --- a/wp-includes/taxonomy.php +++ b/wp-includes/taxonomy.php @@ -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);