When using WP_Query's "fields" => "ids" (or "fields" => "id=>parent"), the returned values should be an array of integers, not array of integers represented by strings.

Adds unit tests. All other unit tests pass.

Props danielbachhuber.
Fixes #27252.


Built from https://develop.svn.wordpress.org/trunk@27686


git-svn-id: http://core.svn.wordpress.org/trunk@27525 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Scott Taylor 2014-03-24 18:55:16 +00:00
parent 540c14079b
commit a6b9d323c6

View File

@ -2268,7 +2268,7 @@ class WP_Query {
// This overrides posts_per_page. // This overrides posts_per_page.
if ( ! empty( $q['posts_per_rss'] ) ) { if ( ! empty( $q['posts_per_rss'] ) ) {
$q['posts_per_page'] = $q['posts_per_rss']; $q['posts_per_page'] = $q['posts_per_rss'];
} else { } else {
$q['posts_per_page'] = get_option( 'posts_per_rss' ); $q['posts_per_page'] = get_option( 'posts_per_rss' );
} }
$q['nopaging'] = false; $q['nopaging'] = false;
@ -3205,7 +3205,7 @@ class WP_Query {
$this->post_count = count( $this->posts ); $this->post_count = count( $this->posts );
$this->set_found_posts( $q, $limits ); $this->set_found_posts( $q, $limits );
return $this->posts; return array_map( 'intval', $this->posts );
} }
if ( 'id=>parent' == $q['fields'] ) { if ( 'id=>parent' == $q['fields'] ) {
@ -3214,9 +3214,9 @@ class WP_Query {
$this->set_found_posts( $q, $limits ); $this->set_found_posts( $q, $limits );
$r = array(); $r = array();
foreach ( $this->posts as $post ) foreach ( $this->posts as $post ) {
$r[ $post->ID ] = $post->post_parent; $r[ (int) $post->ID ] = (int) $post->post_parent;
}
return $r; return $r;
} }