Ticket #21147: fields-found-rows.diff
| File fields-found-rows.diff, 1.8 KB (added by wonderboymusic, 9 months ago) |
|---|
-
wp-includes/query.php
2613 2613 $this->request = apply_filters_ref_array( 'posts_request', array( $this->request, &$this ) ); 2614 2614 } 2615 2615 2616 if ( 'ids' == $q['fields'] ) { 2617 $this->posts = $wpdb->get_col($this->request); 2616 if ( in_array( $q['fields'], array( 'ids', 'id=>parent' ) ) ) { 2617 2618 if ( 'ids' == $q['fields'] ) 2619 $this->posts = $wpdb->get_col( $this->request ); 2618 2620 2621 if ( 'id=>parent' == $q['fields'] ) { 2622 $this->posts = $wpdb->get_results( $this->request ); 2623 $r = array(); 2624 foreach ( $this->posts as $post ) 2625 $r[ $post->ID ] = $post->post_parent; 2626 2627 $this->posts = $r; 2628 } 2629 2630 $this->found_rows = $this->post_count = count( $this->posts ); 2619 2631 return $this->posts; 2620 2632 } 2621 2622 if ( 'id=>parent' == $q['fields'] ) { 2623 $this->posts = $wpdb->get_results($this->request); 2624 2625 $r = array(); 2626 foreach ( $this->posts as $post ) 2627 $r[ $post->ID ] = $post->post_parent; 2628 2629 return $r; 2630 } 2631 2633 2632 2634 $split_the_query = ( $old_request == $this->request && "$wpdb->posts.*" == $fields && !empty( $limits ) && $q['posts_per_page'] < 500 ); 2633 2635 $split_the_query = apply_filters( 'split_the_query', $split_the_query, $this ); 2634 2636 … … 2750 2752 if ( !$q['suppress_filters'] ) 2751 2753 $this->posts = apply_filters_ref_array('the_posts', array( $this->posts, &$this ) ); 2752 2754 2753 $this->post_count = count( $this->posts);2755 $this->post_count = count( $this->posts ); 2754 2756 2755 2757 // Always sanitize 2756 2758 foreach ( $this->posts as $i => $post ) { … … 2770 2772 function set_found_posts( $q, $limits ) { 2771 2773 global $wpdb; 2772 2774 2775 if ( empty( $limits ) ) 2776 $this->found_rows = count( $this->posts ); 2777 2773 2778 if ( $q['no_found_rows'] || empty( $limits ) ) 2774 2779 return; 2775 2780
