Ticket #18536: 18536.diff
File 18536.diff, 2.7 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.' ) ); … … 2591 2592 $$piece = isset( $clauses[ $piece ] ) ? $clauses[ $piece ] : ''; 2592 2593 } 2593 2594 2595 if ( "$wpdb->posts.*" == $fields ) { 2596 $fields = "$wpdb->posts.ID"; 2597 $expand_ids = true; 2598 } 2599 2594 2600 if ( ! empty($groupby) ) 2595 2601 $groupby = 'GROUP BY ' . $groupby; 2596 2602 if ( !empty( $orderby ) ) … … 2606 2612 2607 2613 if ( 'ids' == $q['fields'] ) { 2608 2614 $this->posts = $wpdb->get_col($this->request); 2609 2610 2615 return $this->posts; 2611 } 2616 } elseif ( $expand_ids ) { 2617 $ids = $wpdb->get_col( $this->request ); 2612 2618 2613 if ( 'id=>parent' == $q['fields'] ) { 2619 if ( $ids ) { 2620 if ( !$q['no_found_rows'] && !empty( $limits ) ) { 2621 $found_posts_query = apply_filters_ref_array( 'found_posts_query', array( 'SELECT FOUND_ROWS()', &$this ) ); 2622 $this->found_posts = $wpdb->get_var( $found_posts_query ); 2623 $this->found_posts = apply_filters_ref_array( 'found_posts', array( $this->found_posts, &$this ) ); 2624 $this->max_num_pages = ceil($this->found_posts / $q['posts_per_page']); 2625 } 2626 2627 $query = sprintf( "SELECT $wpdb->posts.* FROM $wpdb->posts WHERE ID IN (%s) $orderby", join( ",", $ids ) ); 2628 $this->posts = $wpdb->get_results($query); 2629 } else { 2630 $this->found_posts = $this->max_num_pages = 0; 2631 $this->posts = array(); 2632 } 2633 } elseif ( 'id=>parent' == $q['fields'] ) { 2614 2634 $this->posts = $wpdb->get_results($this->request); 2615 2635 2616 2636 $r = array(); … … 2618 2638 $r[ $post->ID ] = $post->post_parent; 2619 2639 2620 2640 return $r; 2641 } else { 2642 $this->posts = $wpdb->get_results($this->request); 2621 2643 } 2622 2644 2623 $this->posts = $wpdb->get_results($this->request);2624 2625 2645 // Raw results filter. Prior to status checks. 2626 2646 if ( !$q['suppress_filters'] ) 2627 2647 $this->posts = apply_filters_ref_array('posts_results', array( $this->posts, &$this ) ); … … 2639 2659 $this->comment_count = count($this->comments); 2640 2660 } 2641 2661 2642 if ( !$q['no_found_rows'] && !empty($limits) ) {2662 if ( !$q['no_found_rows'] && !empty($limits) && !$expand_ids ) { 2643 2663 $found_posts_query = apply_filters_ref_array( 'found_posts_query', array( 'SELECT FOUND_ROWS()', &$this ) ); 2644 2664 $this->found_posts = $wpdb->get_var( $found_posts_query ); 2645 2665 $this->found_posts = apply_filters_ref_array( 'found_posts', array( $this->found_posts, &$this ) );