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