Make WordPress Core

Changeset 10416


Ignore:
Timestamp:
01/22/2009 10:59:29 PM (16 years ago)
Author:
ryan
Message:

Don't limit query when descending hierarchy. Props filosofo. fixes #8832

File:
1 edited

Legend:

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

    r10275 r10416  
    737737        $where .= ' AND tt.count > 0';
    738738
    739     if ( !empty($number) ) {
     739    // don't limit the query results when we have to descend the family tree
     740    if ( ! empty($number) && ! $hierarchical && empty( $child_of ) && '' == $parent ) {
    740741        if( $offset )
    741             $number = 'LIMIT ' . $offset . ',' . $number;
     742            $limit = 'LIMIT ' . $offset . ',' . $number;
    742743        else
    743             $number = 'LIMIT ' . $number;
     744            $limit = 'LIMIT ' . $number;
    744745
    745746    } else
    746         $number = '';
     747        $limit = '';
    747748
    748749    if ( !empty($search) ) {
     
    759760        $select_this = 't.term_id, tt.parent, tt.count, t.name';
    760761
    761     $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 $number";
    762 
     762    $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";
     763
     764    $terms = $wpdb->get_results($query);
    763765    if ( 'all' == $fields ) {
    764         $terms = $wpdb->get_results($query);
    765766        update_term_cache($terms);
    766     } else if ( ('ids' == $fields) || ('names' == $fields) ) {
    767         $terms = $wpdb->get_results($query);
    768767    }
    769768
     
    811810            $_terms[] = $term->name;
    812811        $terms = $_terms;
     812    }
     813
     814    if ( 0 < $number && intval(@count($terms)) > $number ) {
     815        $terms = array_slice($terms, $offset, $number);
    813816    }
    814817
Note: See TracChangeset for help on using the changeset viewer.