From 91586ebff486653cbab036bb7a104e16d2c360da Mon Sep 17 00:00:00 2001 From: ryan Date: Fri, 4 Jan 2008 19:55:17 +0000 Subject: [PATCH] Page walk fixes from hailin. fixes #5581 git-svn-id: http://svn.automattic.com/wordpress/trunk@6552 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/template.php | 8 ++++++++ wp-includes/classes.php | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/wp-admin/includes/template.php b/wp-admin/includes/template.php index 609c737c36..9f6f7dac5d 100644 --- a/wp-admin/includes/template.php +++ b/wp-admin/includes/template.php @@ -283,6 +283,14 @@ function page_rows( $pages ) { $children_pages = array(); foreach ( $pages as $page ) { + + // catch and repair bad pages + if ( $page->post_parent == $page->ID ) { + $page->post_parent = 0; + $wpdb->query( $wpdb->prepare("UPDATE $wpdb->posts SET post_parent = '0' WHERE ID = %d", $page->ID) ); + clean_page_cache( $page->ID ); + } + if ( 0 == $page->post_parent ) $top_level_pages[] = $page; else diff --git a/wp-includes/classes.php b/wp-includes/classes.php index 46593385a7..d68f2ce589 100644 --- a/wp-includes/classes.php +++ b/wp-includes/classes.php @@ -434,7 +434,7 @@ class Walker { array_splice( $children_elements, $i, 1 ); $output = $this->display_element( $child, $children_elements, $max_depth, $depth + 1, $args, $output ); - $i--; + $i = -1; } }