Changeset 30735
- Timestamp:
- 12/04/2014 12:23:47 AM (10 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/post.php
r30725 r30735 4285 4285 $page_list = array(); 4286 4286 foreach ( (array) $pages as $page ) { 4287 if ( $page->post_parent == $page_id || in_array( $page_id, $page->ancestors )) {4287 if ( $page->post_parent == $page_id ) { 4288 4288 $page_list[] = $page; 4289 if ( $children = get_page_children( $page->ID, $pages , false) ) {4289 if ( $children = get_page_children( $page->ID, $pages ) ) { 4290 4290 $page_list = array_merge( $page_list, $children ); 4291 4291 } … … 4293 4293 } 4294 4294 4295 // Ensure uniqueness. 4296 $page_ids = array(); 4297 $unique_page_list = array(); 4298 foreach ( $page_list as $page_list_item ) { 4299 if ( ! in_array( $page_list_item->ID, $page_ids ) ) { 4300 $unique_page_list[] = $page_list_item; 4301 $page_ids[] = $page_list_item->ID; 4302 } 4303 } 4304 4305 return $unique_page_list; 4295 return $page_list; 4306 4296 } 4307 4297 … … 4634 4624 update_post_cache( $pages ); 4635 4625 4636 // Convert to WP_Post instances4637 $pages = array_map( 'get_post', $pages );4638 4639 4626 if ( $child_of || $hierarchical ) { 4640 4627 $pages = get_page_children($child_of, $pages); … … 4664 4651 4665 4652 wp_cache_set( $cache_key, $page_structure, 'posts' ); 4653 4654 // Convert to WP_Post instances 4655 $pages = array_map( 'get_post', $pages ); 4666 4656 4667 4657 /** -
trunk/tests/phpunit/tests/post/getPages.php
r30337 r30735 271 271 $this->assertCount( 2, $exclude6 ); 272 272 } 273 274 /**275 * @ticket 14477276 */277 function test_get_pages_interrupted_hierarchy() {278 $page1 = $this->factory->post->create( array( 'post_type' => 'page' ) );279 $page2 = $this->factory->post->create( array( 'post_type' => 'page', 'post_parent' => $page1 ) );280 add_post_meta( $page2, 'color', 'red' );281 $page3 = $this->factory->post->create( array( 'post_type' => 'page', 'post_parent' => $page2 ) );282 add_post_meta( $page3, 'color', 'blue' );283 284 $pages = get_pages( array( 'child_of' => $page1, 'meta_key' => 'color', 'meta_value' => 'blue' ) );285 $this->assertEqualSets( array( $page3 ), wp_list_pluck( $pages, 'ID' ) );286 }287 273 }
Note: See TracChangeset
for help on using the changeset viewer.