From 7a561d0d0096ff01a9a65c65a2b01d0543a57673 Mon Sep 17 00:00:00 2001 From: Ryan Boren Date: Sat, 14 May 2005 02:57:47 +0000 Subject: [PATCH] Make sure cache is primed before use in get_category_children(). git-svn-id: https://develop.svn.wordpress.org/trunk@2608 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/template-functions-category.php | 24 ++++++++++++--------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/wp-includes/template-functions-category.php b/wp-includes/template-functions-category.php index 7cc72acebf..50e256604e 100644 --- a/wp-includes/template-functions-category.php +++ b/wp-includes/template-functions-category.php @@ -123,16 +123,20 @@ function get_category_parents($id, $link = FALSE, $separator = '/', $nicename = } function get_category_children($id, $before = '/', $after = '') { - global $cache_categories; - $c_cache = $cache_categories; // Can't do recursive foreach on a global, have to make a copy - $chain = ''; - foreach ($c_cache as $category){ - if ($category->category_parent == $id){ - $chain .= $before.$category->cat_ID.$after; - $chain .= get_category_children($category->cat_ID, $before, $after); - } - } - return $chain; + global $cache_categories; + + if ( ! isset($cache_categories)) + update_category_cache(); + + $c_cache = $cache_categories; // Can't do recursive foreach on a global, have to make a copy + $chain = ''; + foreach ($c_cache as $category){ + if ($category->category_parent == $id){ + $chain .= $before.$category->cat_ID.$after; + $chain .= get_category_children($category->cat_ID, $before, $after); + } + } + return $chain; } // Deprecated.