Make WordPress Core

Changeset 13647


Ignore:
Timestamp:
03/10/2010 06:37:03 PM (13 years ago)
Author:
ryan
Message:

Add no_found_rows argument to WP_Query::get_posts() to allow forcibly defeating SQL_CALC_FOUND_ROWS. Use no_found_rows for the query in get_boundary_post(). fixes #12557

Location:
trunk/wp-includes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/link-template.php

    r13635 r13647  
    11591159    $order = $start ? 'ASC' : 'DESC';
    11601160
    1161     return get_posts( array('numberposts' => 1, 'order' => $order, 'orderby' => 'ID', 'category' => $categories) );
     1161    return get_posts( array('numberposts' => 1, 'no_found_rows' => true, 'order' => $order, 'orderby' => 'ID', 'category' => $categories) );
    11621162}
    11631163
  • trunk/wp-includes/query.php

    r13615 r13647  
    16731673        }
    16741674
     1675        // If true, forcibly turns off SQL_CALC_FOUND_ROWS even when limits are present.
     1676        if ( isset($q['no_found_rows']) )
     1677            $q['no_found_rows'] = (bool) $q['no_found_rows'];
     1678        else
     1679            $q['no_found_rows'] = false;
     1680
    16751681        // If a month is specified in the querystring, load that month
    16761682        if ( $q['m'] ) {
     
    23322338            $orderby = 'ORDER BY ' . $orderby;
    23332339        $found_rows = '';
    2334         if ( !empty($limits) )
     2340        if ( !$q['no_found_rows'] && !empty($limits) )
    23352341            $found_rows = 'SQL_CALC_FOUND_ROWS';
    23362342
     
    23572363        }
    23582364
    2359         if ( !empty($limits) ) {
     2365        if ( !$q['no_found_rows'] && !empty($limits) ) {
    23602366            $found_posts_query = apply_filters( 'found_posts_query', 'SELECT FOUND_ROWS()' );
    23612367            $this->found_posts = $wpdb->get_var( $found_posts_query );
Note: See TracChangeset for help on using the changeset viewer.