From 74328576c69ae93e24c1fc568902cb184e717ef9 Mon Sep 17 00:00:00 2001 From: ryan Date: Thu, 31 Mar 2005 05:25:54 +0000 Subject: [PATCH] More category cache cleanups. git-svn-id: http://svn.automattic.com/wordpress/trunk@2504 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/admin.php | 5 +---- wp-includes/functions.php | 6 ++++++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/wp-admin/admin.php b/wp-admin/admin.php index 7cf746f9d..777873512 100644 --- a/wp-admin/admin.php +++ b/wp-admin/admin.php @@ -8,10 +8,7 @@ header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); header('Cache-Control: no-cache, must-revalidate, max-age=0'); header('Pragma: no-cache'); -$dogs = $wpdb->get_results("SELECT * FROM $wpdb->categories"); -foreach ($dogs as $catt) { - $cache_categories[$catt->cat_ID] = $catt; -} +update_category_cache(); get_currentuserinfo(); diff --git a/wp-includes/functions.php b/wp-includes/functions.php index d8fde6af9..d1083787c 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -615,6 +615,9 @@ function &get_page(&$page, $output = OBJECT) { function &get_category(&$category, $output = OBJECT) { global $cache_categories, $wpdb; + if ( ! isset($cache_categories)) + update_category_cache(); + if (is_object($category)) { if ( ! isset($cache_categories[$category->cat_ID])) $cache_categories[$category->cat_ID] = &$category; @@ -1170,6 +1173,9 @@ function update_post_category_cache($post_ids) { post_id, category_id FROM $wpdb->categories, $wpdb->post2cat WHERE category_id = cat_ID AND post_id IN ($post_ids)"); + if (! isset($cache_categories)) + update_category_cache(); + if ( !empty($dogs) ) { foreach ($dogs as $catt) { $category_cache[$catt->post_id][$catt->category_id] = &$cache_categories[$catt->category_id];