Make WordPress Core

Changeset 22465


Ignore:
Timestamp:
11/08/2012 01:52:40 PM (12 years ago)
Author:
ryan
Message:

If $this->posts is empty, don't do stuff to it.

Props wonderboymusic
fixes #22061

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/query.php

    r22450 r22465  
    27712771            $this->posts = apply_filters_ref_array('the_posts', array( $this->posts, &$this ) );
    27722772
    2773         $this->post_count = count( $this->posts );
    2774 
    27752773        // Ensure that any posts added/modified via one of the filters above are
    27762774        // of the type WP_Post and are filtered.
    2777         if ( $this->posts )
     2775        if ( $this->posts ) {
     2776            $this->post_count = count( $this->posts );
     2777           
    27782778            $this->posts = array_map( 'get_post', $this->posts );
    27792779
    2780         if ( $q['cache_results'] )
    2781             update_post_caches($this->posts, $post_type, $q['update_post_term_cache'], $q['update_post_meta_cache']);
    2782 
    2783         if ( $this->post_count > 0 ) {
    2784             $this->post = $this->posts[0];
     2780            if ( $q['cache_results'] )
     2781                update_post_caches($this->posts, $post_type, $q['update_post_term_cache'], $q['update_post_meta_cache']);
     2782
     2783            $this->post = reset( $this->posts );           
     2784        } else {
     2785            $this->post_count = 0;
     2786            $this->posts = array();
    27852787        }
    27862788
Note: See TracChangeset for help on using the changeset viewer.