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