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
This commit is contained in:
ryan 2012-03-19 19:09:03 +00:00
parent 7faddb72bc
commit 5b2274941d
1 changed files with 2 additions and 1 deletions

View File

@ -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');
}