Make WordPress Core

Changeset 25160


Ignore:
Timestamp:
08/29/2013 03:07:59 PM (13 years ago)
Author:
wonderboymusic
Message:

Respect the fields arg when passed to get_children().

Fixes #22208.

Location:
trunk
Files:
2 edited

Legend:

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

    r25130 r25160  
    312312        $children = get_posts( $r );
    313313
    314         if ( !$children )
     314        if ( ! $children )
    315315                return $kids;
     316
     317        if ( ! empty( $r['fields'] ) )
     318                return $children;
    316319
    317320        update_post_cache($children);
  • trunk/tests/tests/post/getPages.php

    r25002 r25160  
    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}
Note: See TracChangeset for help on using the changeset viewer.