WordPress.org

Make WordPress Core

Ticket #22208: 22208.3.diff

File 22208.3.diff, 1.3 KB (added by wonderboymusic, 8 years ago)
  • tests/tests/post/getPages.php

     
    117117
    118118                $this->assertEquals( 5, count( $matches[0] ) );
    119119        }
     120
     121        /**
     122         * @ticket 22208
     123         */
     124        function test_get_chidren_fields_ids() {
     125                $post_id = $this->factory->post->create();
     126                $child_ids = $this->factory->post->create_many( 5, array( 'post_parent' => $post_id ) );
     127
     128                $post_ids = get_children( array( 'fields' => 'ids', 'post_parent' => $post_id ) );
     129                $this->assertEqualSets( $child_ids, $post_ids );
     130        }
    120131}
     132 No newline at end of file
  • src/wp-includes/post.php

    Property changes on: tests/data
    ___________________________________________________________________
    Added: svn:ignore
       + .trac-ticket-cache.core.trac.wordpress.org
    
    
     
    311311
    312312        $children = get_posts( $r );
    313313
    314         if ( !$children )
     314        if ( ! $children )
    315315                return $kids;
    316316
     317        if ( isset( $r[ 'fields' ] ) && ( $r['fields'] === 'ids' || $r['fields'] === 'id=>parent' ) )
     318                return $children;
     319       
    317320        update_post_cache($children);
    318321
    319322        foreach ( $children as $key => $child )