Ticket #11047: 11047_break_loop.diff
File 11047_break_loop.diff, 1.7 KB (added by , 16 years ago) |
---|
-
C:/xampp/htdocs/wordpress_trunk/wp-admin/includes/template.php
1565 1565 $post = $global_post; 1566 1566 } 1567 1567 1568 /*1569 * display one row if the page doesn't have any children1570 * otherwise, display the row and its children in subsequent rows1571 */1572 1568 /** 1573 1569 * {@internal Missing Short Description}} 1574 1570 * … … 1578 1574 * @param unknown_type $level 1579 1575 */ 1580 1576 function display_page_row( $page, $level = 0 ) { 1581 global $post ;1577 global $post, $wpdb; 1582 1578 static $rowclass; 1583 1579 1584 1580 $post = $page; 1585 1581 setup_postdata($page); 1586 1582 1587 1583 if ( 0 == $level && (int)$page->post_parent > 0 ) { 1588 //sent level 0 by accident, by default, or because we don't know the actual level 1584 /* 1585 * sent level 0 by accident, by default, or because we don't know the actual level 1586 * detect and fix possible loops here 1587 */ 1589 1588 $find_main_page = (int)$page->post_parent; 1589 1590 $track_parents[] = $find_main_page; 1591 1590 1592 while ( $find_main_page > 0 ) { 1591 1593 $parent = get_page($find_main_page); 1592 1594 … … 1596 1598 $level++; 1597 1599 $find_main_page = (int)$parent->post_parent; 1598 1600 1601 if ( in_array( $find_main_page, $track_parents ) ) { 1602 $parent->post_parent = 0; 1603 $wpdb->query( $wpdb->prepare("UPDATE $wpdb->posts SET post_parent = '0' WHERE ID = %d", $parent->ID) ); 1604 clean_page_cache( $parent->ID ); 1605 break; 1606 } else { 1607 $track_parents[] = $find_main_page; 1608 } 1609 1599 1610 if ( !isset($parent_name) ) 1600 1611 $parent_name = $parent->post_title; 1601 1612 }