WordPress.org

Make WordPress Core

Ticket #10964: 10964.2.diff

File 10964.2.diff, 1.8 KB (added by ryan, 5 years ago)

query.2.php diffed against the 2.8 branch

  • wp-includes/query.php

     
    22482248                $found_rows = ''; 
    22492249                if ( !empty($limits) ) 
    22502250                        $found_rows = 'SQL_CALC_FOUND_ROWS'; 
    2251  
    2252                 $this->request = " SELECT $found_rows $distinct $fields FROM $wpdb->posts $join WHERE 1=1 $where $groupby $orderby $limits"; 
     2251                 
     2252                //////// BELOW CODE MODIFIED BY DAVE BUCHANAN, SPLIT INTO TWO QUERIES ///////////////////// 
     2253                /// FIRST SELECT JUST IDs 
     2254                $tmp = " SELECT $distinct $wpdb->posts.id FROM $wpdb->posts $join WHERE 1=1 $where $groupby $orderby $limits"; 
     2255                $tmp_q = $wpdb->get_col($tmp); 
     2256                $tmp_ids = implode($tmp_q,','); 
     2257                 
     2258                /// NOW NORMAL SELECT WHERE ID IS IN FIRST QUERY LIST 
     2259                $this->request = " SELECT $found_rows $distinct $fields FROM $wpdb->posts $join WHERE $wpdb->posts.id IN ($tmp_ids) $groupby $orderby "; 
     2260                 
     2261                ////OLD ONE ///$this->request = " SELECT $found_rows $distinct $fields FROM $wpdb->posts $join WHERE 1=1 $where $groupby $orderby $limits"; 
     2262                 
    22532263                if ( !$q['suppress_filters'] ) 
    22542264                        $this->request = apply_filters('posts_request', $this->request); 
    22552265 
     
    22722282                } 
    22732283 
    22742284                if ( !empty($limits) ) { 
    2275                         $found_posts_query = apply_filters( 'found_posts_query', 'SELECT FOUND_ROWS()' ); 
     2285                        ////OLD ONE///$found_posts_query = apply_filters( 'found_posts_query', 'SELECT FOUND_ROWS()' ); 
     2286                        ////Dave Buchanan Changed below 
     2287                        $found_posts_query  = " SELECT $distinct count($wpdb->posts.id) FROM $wpdb->posts $join WHERE 1=1 $where"; 
    22762288                        $this->found_posts = $wpdb->get_var( $found_posts_query ); 
    22772289                        $this->found_posts = apply_filters( 'found_posts', $this->found_posts ); 
    22782290                        $this->max_num_pages = ceil($this->found_posts / $q['posts_per_page']);