Ticket #14426: 14426.2.patch
| File 14426.2.patch, 1.8 KB (added by , 13 years ago) |
|---|
-
wp-includes/query.php
2615 2615 2616 2616 if ( 'ids' == $q['fields'] ) { 2617 2617 $this->posts = $wpdb->get_col($this->request); 2618 $this->set_found_posts( $q, $limits ); 2618 2619 2619 2620 return $this->posts; 2620 2621 } 2621 2622 2622 2623 if ( 'id=>parent' == $q['fields'] ) { 2623 2624 $this->posts = $wpdb->get_results($this->request); 2625 $this->set_found_posts( $q, $limits ); 2624 2626 2625 2627 $r = array(); 2626 2628 foreach ( $this->posts as $post ) … … 2642 2644 $ids = $wpdb->get_col( $this->request ); 2643 2645 2644 2646 if ( $ids ) { 2647 $this->posts = $ids; 2645 2648 $this->set_found_posts( $q, $limits ); 2646 2649 _prime_post_caches( $ids, $q['update_post_term_cache'], $q['update_post_meta_cache'] ); 2647 $this->posts = $ids;2648 2650 } else { 2649 2651 $this->posts = array(); 2650 $this->found_posts = $this->max_num_pages = 0;2651 2652 } 2652 2653 } else { 2653 2654 $this->posts = $wpdb->get_results( $this->request ); … … 2770 2771 function set_found_posts( $q, $limits ) { 2771 2772 global $wpdb; 2772 2773 2773 if ( $q['no_found_rows'] || empty( $limits ))2774 if ( $q['no_found_rows'] || ! $this->posts ) 2774 2775 return; 2775 2776 2776 $this->found_posts = $wpdb->get_var( apply_filters_ref_array( 'found_posts_query', array( 'SELECT FOUND_ROWS()', &$this ) ) ); 2777 if ( ! empty( $limits ) ) 2778 $this->found_posts = $wpdb->get_var( apply_filters_ref_array( 'found_posts_query', array( 'SELECT FOUND_ROWS()', &$this ) ) ); 2779 else 2780 $this->found_posts = count( $this->posts ); 2781 2777 2782 $this->found_posts = apply_filters_ref_array( 'found_posts', array( $this->found_posts, &$this ) ); 2778 2783 2779 $this->max_num_pages = ceil( $this->found_posts / $q['posts_per_page'] ); 2784 if ( ! empty( $limits ) ) 2785 $this->max_num_pages = ceil( $this->found_posts / $q['posts_per_page'] ); 2780 2786 } 2781 2787 2782 2788 /**