Make WordPress Core

Ticket #36687: 36687.3.diff

File 36687.3.diff, 2.6 KB (added by spacedmonkey, 7 years ago)
  • src/wp-includes/query.php

     
    35743574                 */
    35753575                $this->posts = apply_filters_ref_array( 'posts_pre_query', array( null, &$this ) );
    35763576
    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 
    35893577                if ( 'id=>parent' == $q['fields'] ) {
    35903578                        if ( null === $this->posts ) {
    35913579                                $this->posts = $wpdb->get_results( $this->request );
     
    36063594                }
    36073595
    36083596                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 ) );
    36103598
    36113599                        /**
    36123600                         * Filters whether to split the query.
     
    36413629
    36423630                                if ( $ids ) {
    36433631                                        $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                                        }
    36463635                                } else {
    36473636                                        $this->posts = array();
    36483637                                }
    36493638                        } else {
    36503639                                $this->posts = $wpdb->get_results( $this->request );
    3651                                 $this->set_found_posts( $q, $limits );
    36523640                        }
    36533641                }
    36543642
    3655                 // Convert to WP_Post objects.
     3643                // Convert to WP_Post objects and set the found-post totals.
    36563644                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 );
    36583651                }
    36593652
    36603653                if ( ! $q['suppress_filters'] ) {
     
    36693662                        $this->posts = apply_filters_ref_array( 'posts_results', array( $this->posts, &$this ) );
    36703663                }
    36713664
     3665
     3666                if ( 'ids' == $q['fields'] ) {
     3667                        $this->post_count = count( $this->posts );
     3668                        return $this->posts;
     3669                }
     3670
    36723671                if ( !empty($this->posts) && $this->is_comment_feed && $this->is_singular ) {
    36733672                        /** This filter is documented in wp-includes/query.php */
    36743673                        $cjoin = apply_filters_ref_array( 'comment_feed_join', array( '', &$this ) );