Ticket #36687: 36687.3.diff
File 36687.3.diff, 2.6 KB (added by , 7 years ago) |
---|
-
src/wp-includes/query.php
3574 3574 */ 3575 3575 $this->posts = apply_filters_ref_array( 'posts_pre_query', array( null, &$this ) ); 3576 3576 3577 if ( 'ids' == $q['fields'] ) {3578 if ( null === $this->posts ) {3579 $this->posts = $wpdb->get_col( $this->request );3580 }3581 3582 $this->posts = array_map( 'intval', $this->posts );3583 $this->post_count = count( $this->posts );3584 $this->set_found_posts( $q, $limits );3585 3586 return $this->posts;3587 }3588 3589 3577 if ( 'id=>parent' == $q['fields'] ) { 3590 3578 if ( null === $this->posts ) { 3591 3579 $this->posts = $wpdb->get_results( $this->request ); … … 3606 3594 } 3607 3595 3608 3596 if ( null === $this->posts ) { 3609 $split_the_query = ( $old_request == $this->request && "$wpdb->posts.*" == $fields && !empty( $limits ) && $q['posts_per_page'] < 500);3597 $split_the_query = ( 'ids' == $q['fields'] || ( $old_request == $this->request && "$wpdb->posts.*" == $fields && ! empty( $limits ) && $q['posts_per_page'] < 500 ) ); 3610 3598 3611 3599 /** 3612 3600 * Filters whether to split the query. … … 3641 3629 3642 3630 if ( $ids ) { 3643 3631 $this->posts = $ids; 3644 $this->set_found_posts( $q, $limits ); 3645 _prime_post_caches( $ids, $q['update_post_term_cache'], $q['update_post_meta_cache'] ); 3632 if ( 'all' == $q['fields'] ) { 3633 _prime_post_caches( $ids, $q['update_post_term_cache'], $q['update_post_meta_cache'] ); 3634 } 3646 3635 } else { 3647 3636 $this->posts = array(); 3648 3637 } 3649 3638 } else { 3650 3639 $this->posts = $wpdb->get_results( $this->request ); 3651 $this->set_found_posts( $q, $limits );3652 3640 } 3653 3641 } 3654 3642 3655 // Convert to WP_Post objects .3643 // Convert to WP_Post objects and set the found-post totals. 3656 3644 if ( $this->posts ) { 3657 $this->posts = array_map( 'get_post', $this->posts ); 3645 if ( 'ids' == $q['fields'] ) { 3646 $this->posts = array_map( 'intval', $this->posts ); 3647 } else { 3648 $this->posts = array_map( 'get_post', $this->posts ); 3649 } 3650 $this->set_found_posts( $q, $limits ); 3658 3651 } 3659 3652 3660 3653 if ( ! $q['suppress_filters'] ) { … … 3669 3662 $this->posts = apply_filters_ref_array( 'posts_results', array( $this->posts, &$this ) ); 3670 3663 } 3671 3664 3665 3666 if ( 'ids' == $q['fields'] ) { 3667 $this->post_count = count( $this->posts ); 3668 return $this->posts; 3669 } 3670 3672 3671 if ( !empty($this->posts) && $this->is_comment_feed && $this->is_singular ) { 3673 3672 /** This filter is documented in wp-includes/query.php */ 3674 3673 $cjoin = apply_filters_ref_array( 'comment_feed_join', array( '', &$this ) );