Ticket #14477: 14477.4.diff
File 14477.4.diff, 2.0 KB (added by , 10 years ago) |
---|
-
src/wp-includes/post.php
4290 4290 function get_page_children($page_id, $pages) { 4291 4291 $page_list = array(); 4292 4292 foreach ( (array) $pages as $page ) { 4293 if ( $page->post_parent == $page_id ) {4293 if ( $page->post_parent == $page_id || in_array( $page_id, $page->ancestors ) ) { 4294 4294 $page_list[] = $page; 4295 4295 if ( $children = get_page_children($page->ID, $pages) ) 4296 4296 $page_list = array_merge($page_list, $children); … … 4624 4624 // Update cache. 4625 4625 update_post_cache( $pages ); 4626 4626 4627 // Convert to WP_Post instances 4628 $pages = array_map( 'get_post', $pages ); 4629 4627 4630 if ( $child_of || $hierarchical ) { 4628 4631 $pages = get_page_children($child_of, $pages); 4629 4632 } … … 4652 4655 4653 4656 wp_cache_set( $cache_key, $page_structure, 'posts' ); 4654 4657 4655 // Convert to WP_Post instances.4656 $pages = array_map( 'get_post', $pages );4657 4658 4658 /** 4659 4659 * Filter the retrieved list of pages. 4660 4660 * -
tests/phpunit/tests/post/getPages.php
268 268 $exclude6 = get_pages( array( 'exclude_tree' => array( $post_id1, $post_id3 ) ) ); 269 269 $this->assertCount( 2, $exclude6 ); 270 270 } 271 272 function test_get_pages_interrupted_hierarchy() { 273 $page1 = $this->factory->post->create( array( 'post_type' => 'page' ) ); 274 $page2 = $this->factory->post->create( array( 'post_type' => 'page', 'post_parent' => $page1 ) ); 275 add_post_meta( $page2, 'color', 'red' ); 276 $page3 = $this->factory->post->create( array( 'post_type' => 'page', 'post_parent' => $page2 ) ); 277 add_post_meta( $page3, 'color', 'blue' ); 278 279 $pages = get_pages( array( 'child_of' => $page1, 'meta_key' => 'color', 'meta_value' => 'blue' ) ); 280 $this->assertEqualSets( array( $page3 ), wp_list_pluck( $pages, 'ID' ) ); 281 } 271 282 } 283 No newline at end of file