Ticket #18536: query.patch
File query.patch, 2.5 KB (added by , 13 years ago) |
---|
-
wp-includes/query.php
1940 1940 $fields = ''; 1941 1941 $post_status_join = false; 1942 1942 $page = 1; 1943 $expand_ids = false; 1943 1944 1944 1945 if ( isset( $q['caller_get_posts'] ) ) { 1945 1946 _deprecated_argument( 'WP_Query', '3.1', __( '"caller_get_posts" is deprecated. Use "ignore_sticky_posts" instead.' ) ); … … 2026 2027 $fields = "$wpdb->posts.ID, $wpdb->posts.post_parent"; 2027 2028 break; 2028 2029 default: 2029 $fields = "$wpdb->posts.*"; 2030 $fields = "$wpdb->posts.ID"; 2031 $expand_ids = true; 2030 2032 } 2031 2033 2032 2034 // If a month is specified in the querystring, load that month … … 2606 2608 2607 2609 if ( 'ids' == $q['fields'] ) { 2608 2610 $this->posts = $wpdb->get_col($this->request); 2609 2610 2611 return $this->posts; 2611 } 2612 } elseif($expand_ids) { 2613 $ids = $wpdb->get_col($this->request); 2612 2614 2613 if ( 'id=>parent' == $q['fields'] ) { 2615 if ( !$q['no_found_rows'] && !empty($limits) ) { 2616 $found_posts_query = apply_filters_ref_array( 'found_posts_query', array( 'SELECT FOUND_ROWS()', &$this ) ); 2617 $this->found_posts = $wpdb->get_var( $found_posts_query ); 2618 $this->found_posts = apply_filters_ref_array( 'found_posts', array( $this->found_posts, &$this ) ); 2619 $this->max_num_pages = ceil($this->found_posts / $q['posts_per_page']); 2620 } 2621 2622 $query = sprintf("SELECT $wpdb->posts.* FROM $wpdb->posts WHERE ID IN (%s) $orderby", join(",", $ids)); 2623 $this->posts = $wpdb->get_results($query); 2624 } elseif ( 'id=>parent' == $q['fields'] ) { 2614 2625 $this->posts = $wpdb->get_results($this->request); 2615 2626 2616 2627 $r = array(); … … 2618 2629 $r[ $post->ID ] = $post->post_parent; 2619 2630 2620 2631 return $r; 2632 } else { 2633 $this->posts = $wpdb->get_results($this->request); 2621 2634 } 2622 2635 2623 $this->posts = $wpdb->get_results($this->request);2624 2625 2636 // Raw results filter. Prior to status checks. 2626 2637 if ( !$q['suppress_filters'] ) 2627 2638 $this->posts = apply_filters_ref_array('posts_results', array( $this->posts, &$this ) ); … … 2639 2650 $this->comment_count = count($this->comments); 2640 2651 } 2641 2652 2642 if ( !$q['no_found_rows'] && !empty($limits) ) {2653 if ( !$q['no_found_rows'] && !empty($limits) && !$expand_ids ) { 2643 2654 $found_posts_query = apply_filters_ref_array( 'found_posts_query', array( 'SELECT FOUND_ROWS()', &$this ) ); 2644 2655 $this->found_posts = $wpdb->get_var( $found_posts_query ); 2645 2656 $this->found_posts = apply_filters_ref_array( 'found_posts', array( $this->found_posts, &$this ) );