Ticket #14662: 14662.2.diff
| File 14662.2.diff, 4.5 KB (added by , 16 years ago) |
|---|
-
wp-includes/post.php
366 366 } elseif ( is_object($post) && empty($post->filter) ) { 367 367 _get_post_ancestors($post); 368 368 $_post = sanitize_post($post, 'raw'); 369 if ( $cached_post = wp_cache_get($_post->ID, 'posts') ) { 370 if ( ! isset($cached_post->ancestors) ) 371 wp_cache_delete($_post->ID, 'posts'); 372 } 373 unset($cached_post); 369 374 wp_cache_add($post->ID, $_post, 'posts'); 370 375 } else { 371 376 if ( is_object($post) ) … … 381 386 _get_post_ancestors($_post); 382 387 $_post = sanitize_post($_post, 'raw'); 383 388 wp_cache_add($_post->ID, $_post, 'posts'); 389 } elseif ( ! isset($_post->ancestors) ) { 390 _get_post_ancestors($_post); 391 wp_cache_set($_post->ID, $_post, 'posts'); 384 392 } 385 393 } 386 394 387 if ( $filter != 'raw')395 if ( $filter != 'raw' ) 388 396 $_post = sanitize_post($_post, $filter); 389 397 390 398 if ( $output == OBJECT ) { … … 2265 2273 else 2266 2274 $post_parent = 0; 2267 2275 2276 // Ancestor circular dependency detection 2268 2277 if ( !empty($post_ID) ) { 2269 2278 if ( $post_parent == $post_ID ) { 2270 2279 // Post can't be its own parent 2271 2280 $post_parent = 0; 2272 2281 } elseif ( !empty($post_parent) ) { 2273 $parent_post = get_post($post_parent); 2274 // Check for circular dependency 2275 if ( isset( $parent_post->post_parent ) && $parent_post->post_parent == $post_ID ) 2276 $post_parent = 0; 2282 $parent_id = $post_parent; 2283 $ancestors = array( $post_ID, $parent_id ); 2284 while ( $ancestor = $wpdb->get_var( $wpdb->prepare("SELECT `post_parent` FROM $wpdb->posts WHERE ID = %d LIMIT 1", $parent_id) ) ) { 2285 // Loop detection: If the ancestor has been seen before, set parent to 0 and break. 2286 if ( in_array($ancestor, $ancestors) ) { 2287 $post_parent = 0; 2288 break; 2289 } 2290 $parent_id = $ancestors[] = $ancestor; 2291 } 2292 unset($ancestors); 2277 2293 } 2278 2294 } 2279 2295 … … 3011 3027 * @return string Page URI. 3012 3028 */ 3013 3029 function get_page_uri($page) { 3014 if ( ! is_object($page) ) 3015 $page = get_page($page); 3030 $page = get_page($page); 3016 3031 $uri = $page->post_name; 3017 3032 3018 3033 // A page cannot be it's own parent. 3019 if ( $page->post_parent == $page->ID )3034 if ( $page->post_parent == $page->ID || 0 == $page->post_parent ) 3020 3035 return $uri; 3021 3036 3022 while ($page->post_parent != 0) {3023 $page = get_page($ page->post_parent);3037 foreach ( $page->ancestors as $ancestor) { 3038 $page = get_page($ancestor); 3024 3039 $uri = $page->post_name . "/" . $uri; 3025 3040 } 3026 3041 … … 4327 4342 if ( empty($_post->post_parent) || $_post->ID == $_post->post_parent ) 4328 4343 return; 4329 4344 4330 $ id = $_post->ancestors[]= $_post->post_parent;4331 while ( $ancestor = $wpdb->get_var( $wpdb->prepare("SELECT `post_parent` FROM $wpdb->posts WHERE ID = %d LIMIT 1", $id) )) {4345 $ancestor = $_post->post_parent; 4346 while ( $ancestor ) { 4332 4347 // Loop detection: If the ancestor has been seen before, break. 4333 4348 if ( ( $ancestor == $_post->ID ) || in_array($ancestor, $_post->ancestors) ) 4334 4349 break; 4335 $id = $_post->ancestors[] = $ancestor; 4350 $_post->ancestors[] = $ancestor; 4351 if ( false === ( $ancestor = wp_cache_get($ancestor, 'posts') ) ) { 4352 $ancestor = $wpdb->get_var( $wpdb->prepare("SELECT `post_parent` FROM $wpdb->posts WHERE ID = %d LIMIT 1", $ancestor) ); 4353 } else { 4354 $ancestor = $ancestor->post_parent; 4355 } 4336 4356 } 4337 4357 } 4338 4358 -
wp-admin/includes/default-list-tables.php
333 333 $children_pages = array(); 334 334 335 335 foreach ( $pages as $page ) { 336 336 $page = get_post($page); 337 337 // catch and repair bad pages 338 338 if ( $page->post_parent == $page->ID ) { 339 339 $page->post_parent = 0; … … 479 479 480 480 if ( 0 == $level && (int) $post->post_parent > 0 ) { 481 481 //sent level 0 by accident, by default, or because we don't know the actual level 482 $find_main_page = (int) $post->post_parent; 483 while ( $find_main_page > 0 ) { 484 $parent = get_page( $find_main_page ); 482 $level = count($post->ancestors); 485 483 486 if ( is_null( $parent ) ) 487 break; 484 $parent = get_page( $post->ancestors[$level] ); 488 485 489 $level++; 490 $find_main_page = (int) $parent->post_parent; 491 492 if ( !isset( $parent_name ) ) 493 $parent_name = $parent->post_title; 494 } 486 if ( !isset( $parent_name ) ) 487 $parent_name = $parent->post_title; 495 488 } 496 489 497 490 $post->post_title = esc_html( $post->post_title );
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)