From d51b58448f7fec88d8e1e7dda65b27263d1cc6cd Mon Sep 17 00:00:00 2001 From: Ryan Boren Date: Thu, 7 Sep 2006 17:42:24 +0000 Subject: [PATCH] Avoid infinite loop when category_parent equals cat_ID git-svn-id: https://develop.svn.wordpress.org/trunk@4173 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/category-template.php | 2 +- wp-includes/category.php | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/wp-includes/category-template.php b/wp-includes/category-template.php index c50b969c66..346fbb6329 100644 --- a/wp-includes/category-template.php +++ b/wp-includes/category-template.php @@ -47,7 +47,7 @@ function get_category_parents($id, $link = FALSE, $separator = '/', $nicename = else $name = $parent->cat_name; - if ( $parent->category_parent ) + if ( $parent->category_parent && ($parent->category_parent != $parent->cat_ID) ) $chain .= get_category_parents($parent->category_parent, $link, $separator, $nicename); if ( $link ) diff --git a/wp-includes/category.php b/wp-includes/category.php index 648ef4f0fa..6ffb2100c3 100644 --- a/wp-includes/category.php +++ b/wp-includes/category.php @@ -172,7 +172,7 @@ function get_category_by_path($category_path, $full_match = true, $output = OBJE foreach ($categories as $category) { $path = '/' . $leaf_path; $curcategory = $category; - while ($curcategory->category_parent != 0) { + while ( ($curcategory->category_parent != 0) && ($curcategory->category_parent != $curcategory->cat_ID) ) { $curcategory = $wpdb->get_row("SELECT cat_ID, category_nicename, category_parent FROM $wpdb->categories WHERE cat_ID = '$curcategory->category_parent'"); $path = '/' . $curcategory->category_nicename . $path; } @@ -219,6 +219,9 @@ function &_get_cat_children($category_id, $categories) { $category_list = array(); foreach ( $categories as $category ) { + if ( $category->cat_ID == $category_id ) + continue; + if ( $category->category_parent == $category_id ) { $category_list[] = $category; if ( $children = _get_cat_children($category->cat_ID, $categories) )