Make WordPress Core

Changeset 30735


Ignore:
Timestamp:
12/04/2014 12:23:47 AM (9 years ago)
Author:
wonderboymusic
Message:

Give up on making uninterrupted hierarchies work in get_page_children() for now, reverts [30159], [30246], [30636].

Props boonebgorges.
See #14477.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/post.php

    r30725 r30735  
    42854285    $page_list = array();
    42864286    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 ) {
    42884288            $page_list[] = $page;
    4289             if ( $children = get_page_children( $page->ID, $pages, false ) ) {
     4289            if ( $children = get_page_children( $page->ID, $pages ) ) {
    42904290                $page_list = array_merge( $page_list, $children );
    42914291            }
     
    42934293    }
    42944294
    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;
    43064296}
    43074297
     
    46344624    update_post_cache( $pages );
    46354625
    4636     // Convert to WP_Post instances
    4637     $pages = array_map( 'get_post', $pages );
    4638 
    46394626    if ( $child_of || $hierarchical ) {
    46404627        $pages = get_page_children($child_of, $pages);
     
    46644651
    46654652    wp_cache_set( $cache_key, $page_structure, 'posts' );
     4653
     4654    // Convert to WP_Post instances
     4655    $pages = array_map( 'get_post', $pages );
    46664656
    46674657    /**
  • trunk/tests/phpunit/tests/post/getPages.php

    r30337 r30735  
    271271        $this->assertCount( 2, $exclude6 );
    272272    }
    273 
    274     /**
    275      * @ticket 14477
    276      */
    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     }
    287273}
Note: See TracChangeset for help on using the changeset viewer.