Respect the `fields` arg when passed to `get_children()`.

Fixes #22208.



git-svn-id: https://develop.svn.wordpress.org/trunk@25160 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Scott Taylor 2013-08-29 15:07:59 +00:00
parent 95cab73341
commit 744a4a80a4
2 changed files with 15 additions and 1 deletions

View File

@ -311,9 +311,12 @@ function get_children($args = '', $output = OBJECT) {
$children = get_posts( $r );
if ( !$children )
if ( ! $children )
return $kids;
if ( ! empty( $r['fields'] ) )
return $children;
update_post_cache($children);
foreach ( $children as $key => $child )

View File

@ -117,4 +117,15 @@ class Tests_Post_getPages extends WP_UnitTestCase {
$this->assertEquals( 5, count( $matches[0] ) );
}
/**
* @ticket 22208
*/
function test_get_chidren_fields_ids() {
$post_id = $this->factory->post->create();
$child_ids = $this->factory->post->create_many( 5, array( 'post_parent' => $post_id ) );
$post_ids = get_children( array( 'fields' => 'ids', 'post_parent' => $post_id ) );
$this->assertEqualSets( $child_ids, $post_ids );
}
}