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.



git-svn-id: https://develop.svn.wordpress.org/trunk@27686 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Scott Taylor
2014-03-24 18:54:38 +00:00
parent 651b4a5f5b
commit 710f11f2df
2 changed files with 41 additions and 9 deletions

View File

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