Make WordPress Core

Ticket #41678: 41678.diff

File 41678.diff, 5.8 KB (added by spacedmonkey, 8 years ago)
  • src/wp-content/themes/twentyseventeen/index.php

     
    3232                <main id="main" class="site-main" role="main">
    3333
    3434                        <?php
     35
     36
     37
    3538                        if ( have_posts() ) :
    3639
    3740                                /* Start the Loop */
  • src/wp-includes/class-wp-query.php

     
    17631763                        case 'ids':
    17641764                                $fields = "{$wpdb->posts}.ID";
    17651765                                break;
    1766                         case 'id=>parent':
    1767                                 $fields = "{$wpdb->posts}.ID, {$wpdb->posts}.post_parent";
    1768                                 break;
    17691766                        default:
    17701767                                $fields = "{$wpdb->posts}.*";
    17711768                }
     
    27552752                 */
    27562753                $this->posts = apply_filters_ref_array( 'posts_pre_query', array( null, &$this ) );
    27572754
    2758                 if ( 'ids' == $q['fields'] ) {
    2759                         if ( null === $this->posts ) {
    2760                                 $this->posts = $wpdb->get_col( $this->request );
    2761                         }
    2762 
    2763                         $this->posts = array_map( 'intval', $this->posts );
    2764                         $this->post_count = count( $this->posts );
    2765                         $this->set_found_posts( $q, $limits );
    2766 
    2767                         return $this->posts;
    2768                 }
    2769 
    2770                 if ( 'id=>parent' == $q['fields'] ) {
    2771                         if ( null === $this->posts ) {
    2772                                 $this->posts = $wpdb->get_results( $this->request );
    2773                         }
    2774 
    2775                         $this->post_count = count( $this->posts );
    2776                         $this->set_found_posts( $q, $limits );
    2777 
    2778                         $r = array();
    2779                         foreach ( $this->posts as $key => $post ) {
    2780                                 $this->posts[ $key ]->ID = (int) $post->ID;
    2781                                 $this->posts[ $key ]->post_parent = (int) $post->post_parent;
    2782 
    2783                                 $r[ (int) $post->ID ] = (int) $post->post_parent;
    2784                         }
    2785 
    2786                         return $r;
    2787                 }
    2788 
    27892755                if ( null === $this->posts ) {
    2790                         $split_the_query = ( $old_request == $this->request && "{$wpdb->posts}.*" == $fields && !empty( $limits ) && $q['posts_per_page'] < 500 );
     2756                        if ( "{$wpdb->posts}.ID" == $fields ) {
     2757                                $split_the_query = true;
     2758                        } else if ( "{$wpdb->posts}.*" == $fields ) {
     2759                                $split_the_query = ( $old_request == $this->request && ! empty( $limits ) && $q['posts_per_page'] < 500 );
    27912760
    2792                         /**
    2793                          * Filters whether to split the query.
    2794                          *
    2795                          * Splitting the query will cause it to fetch just the IDs of the found posts
    2796                          * (and then individually fetch each post by ID), rather than fetching every
    2797                          * complete row at once. One massive result vs. many small results.
    2798                          *
    2799                          * @since 3.4.0
    2800                          *
    2801                          * @param bool     $split_the_query Whether or not to split the query.
    2802                          * @param WP_Query $this            The WP_Query instance.
    2803                          */
    2804                         $split_the_query = apply_filters( 'split_the_query', $split_the_query, $this );
     2761                                /**
     2762                                 * Filters whether to split the query.
     2763                                 *
     2764                                 * Splitting the query will cause it to fetch just the IDs of the found posts
     2765                                 * (and then individually fetch each post by ID), rather than fetching every
     2766                                 * complete row at once. One massive result vs. many small results.
     2767                                 *
     2768                                 * @since 3.4.0
     2769                                 *
     2770                                 * @param bool $split_the_query Whether or not to split the query.
     2771                                 * @param WP_Query $this The WP_Query instance.
     2772                                 */
     2773                                $split_the_query = apply_filters( 'split_the_query', $split_the_query, $this );
     2774                        }
    28052775
    28062776                        if ( $split_the_query ) {
    28072777                                // First get the IDs and then fill in the objects
     
    28232793                                if ( $ids ) {
    28242794                                        $this->posts = $ids;
    28252795                                        $this->set_found_posts( $q, $limits );
    2826                                         _prime_post_caches( $ids, $q['update_post_term_cache'], $q['update_post_meta_cache'] );
     2796                                        if ( 'ids' !== $q['fields'] ) {
     2797                                                _prime_post_caches( $ids, $q['update_post_term_cache'], $q['update_post_meta_cache'] );
     2798                                        }
    28272799                                } else {
    28282800                                        $this->posts = array();
    28292801                                }
     
    28332805                        }
    28342806                }
    28352807
    2836                 // Convert to WP_Post objects.
    28372808                if ( $this->posts ) {
    2838                         $this->posts = array_map( 'get_post', $this->posts );
     2809                        if ( 'ids' == $q['fields'] ) {
     2810                                $this->posts = array_map( 'intval', $this->posts );
     2811                        } else {
     2812                                // Convert to WP_Post objects.
     2813                                $this->posts = array_map( 'get_post', $this->posts );
     2814                        }
    28392815                }
    28402816
    28412817                if ( ! $q['suppress_filters'] ) {
    2842                         /**
    2843                          * Filters the raw post results array, prior to status checks.
    2844                          *
    2845                          * @since 2.3.0
    2846                          *
    2847                          * @param array    $posts The post results array.
    2848                          * @param WP_Query &$this The WP_Query instance (passed by reference).
    2849                          */
    2850                         $this->posts = apply_filters_ref_array( 'posts_results', array( $this->posts, &$this ) );
     2818                        if ( 'ids' == $q['fields'] ) {
     2819                                /**
     2820                                 * Filters the raw ids results array, prior to status checks.
     2821                                 *
     2822                                 * @since 4.9.0
     2823                                 *
     2824                                 * @param array $posts The post ids results array.
     2825                                 * @param WP_Query &$this The WP_Query instance (passed by reference).
     2826                                 */
     2827                                $this->posts = apply_filters_ref_array( 'posts_results_ids', array( $this->posts, &$this ) );
     2828                        } else {
     2829                                /**
     2830                                 * Filters the raw post results array, prior to status checks.
     2831                                 *
     2832                                 * @since 2.3.0
     2833                                 *
     2834                                 * @param array $posts The post results array.
     2835                                 * @param WP_Query &$this The WP_Query instance (passed by reference).
     2836                                 */
     2837                                $this->posts = apply_filters_ref_array( 'posts_results', array( $this->posts, &$this ) );
     2838                        }
     2839                }
     2840
     2841                if ( 'ids' == $q['fields'] ) {
     2842                        $this->post_count = count( $this->posts );
     2843                        return $this->posts;
    28512844                }
    28522845
    28532846                if ( !empty($this->posts) && $this->is_comment_feed && $this->is_singular ) {
     
    29982991                        $this->posts = array();
    29992992                }
    30002993
     2994
     2995                if ( 'id=>parent' == $q['fields'] ) {
     2996                        $r = array();
     2997                        foreach ( $this->posts as $key => $post ) {
     2998                                $this->posts[ $key ]->ID = (int) $post->ID;
     2999                                $this->posts[ $key ]->post_parent = (int) $post->post_parent;
     3000
     3001                                $r[ (int) $post->ID ] = (int) $post->post_parent;
     3002                        }
     3003
     3004                        return $r;
     3005                }
     3006
    30013007                if ( $q['lazy_load_term_meta'] ) {
    30023008                        wp_queue_posts_for_term_meta_lazyload( $this->posts );
    30033009                }