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:
parent
540c14079b
commit
a6b9d323c6
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue