mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2025-10-16 12:05:38 +00:00
Add some more cache handling to get_category().
git-svn-id: https://develop.svn.wordpress.org/trunk@2500 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
92bfcd3e37
commit
7d59187e7a
@ -611,14 +611,23 @@ function &get_page(&$page, $output = OBJECT) {
|
||||
}
|
||||
|
||||
// Retrieves category data given a category ID or category object.
|
||||
// The category cache is fully populated by the blog header, so we don't
|
||||
// have to worry with managing it here.
|
||||
// Handles category caching.
|
||||
function &get_category(&$category, $output = OBJECT) {
|
||||
global $cache_categories;
|
||||
if (is_object($category))
|
||||
global $cache_categories, $wpdb;
|
||||
|
||||
if (is_object($category)) {
|
||||
if ( ! isset($cache_categories[$category->cat_ID]))
|
||||
$cache_categories[$category->cat_ID] = &$category;
|
||||
$category = & $cache_categories[$category->cat_ID];
|
||||
else
|
||||
$category = & $cache_categories[$category];
|
||||
} else {
|
||||
if ( !isset($cache_categories[$category]) ) {
|
||||
$category = $wpdb->get_row("SELECT * FROM $wpdb->categories WHERE cat_ID = $category");
|
||||
$category->category_id = $category->cat_ID; // Alias.
|
||||
$cache_categories[$category] = & $category;
|
||||
} else {
|
||||
$category = & $cache_categories[$category];
|
||||
}
|
||||
}
|
||||
|
||||
if ( $output == OBJECT ) {
|
||||
return $category;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user