Make WordPress Core

Changeset 20216


Ignore:
Timestamp:
03/19/2012 07:09:03 PM (13 years ago)
Author:
ryan
Message:

Don't generate a query when the all_page_ids cache is an empty array. An empty array is a valid cache value when no pages are present. Avoids a useless query for sites with no pages. Props andy. see #20236

File:
1 edited

Legend:

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

    r20172 r20216  
    31253125    global $wpdb;
    31263126
    3127     if ( ! $page_ids = wp_cache_get('all_page_ids', 'posts') ) {
     3127    $page_ids = wp_cache_get('all_page_ids', 'posts');
     3128    if ( ! is_array( $page_ids ) ) {
    31283129        $page_ids = $wpdb->get_col("SELECT ID FROM $wpdb->posts WHERE post_type = 'page'");
    31293130        wp_cache_add('all_page_ids', $page_ids, 'posts');
Note: See TracChangeset for help on using the changeset viewer.