From 5b2274941d47ce0bc399c1be4417e50ea59d703c Mon Sep 17 00:00:00 2001 From: ryan Date: Mon, 19 Mar 2012 19:09:03 +0000 Subject: [PATCH] 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 git-svn-id: http://svn.automattic.com/wordpress/trunk@20216 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/post.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/wp-includes/post.php b/wp-includes/post.php index 630b9b349..7fb3ba71e 100644 --- a/wp-includes/post.php +++ b/wp-includes/post.php @@ -3124,7 +3124,8 @@ function trackback_url_list($tb_list, $post_id) { function get_all_page_ids() { global $wpdb; - if ( ! $page_ids = wp_cache_get('all_page_ids', 'posts') ) { + $page_ids = wp_cache_get('all_page_ids', 'posts'); + if ( ! is_array( $page_ids ) ) { $page_ids = $wpdb->get_col("SELECT ID FROM $wpdb->posts WHERE post_type = 'page'"); wp_cache_add('all_page_ids', $page_ids, 'posts'); }