[wp-trac] [WordPress Trac] #31194: WP_Query's 'fields' => 'ids' still returns an array of strings
WordPress Trac
noreply at wordpress.org
Sun Feb 1 04:42:08 UTC 2015
#31194: WP_Query's 'fields' => 'ids' still returns an array of strings
----------------------------+-----------------------
Reporter: SergeyBiryukov | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: 4.2
Component: Query | Version: 3.9
Severity: normal | Keywords: has-patch
Focuses: |
----------------------------+-----------------------
#27252 attempted to make WP_Query's `'fields' => 'ids'` or `'fields' =>
'id=>parent'` return an array of integers instead of numeric strings.
However, the fix was incomplete.
This returns an array of integers:
{{{
$query = new WP_Query();
$posts = $query->query( array( 'fields' => 'ids' ) );
var_dump( $posts );
array(1) {
[0]=>
int(131)
}
}}}
This still returns an array of strings:
{{{
$query = new WP_Query( array( 'fields' => 'ids' ) );
var_dump( $query->posts );
array(1) {
[0]=>
string(3) "131"
}
}}}
The unit test added in [27686] didn't catch this, because it only tested
`$q->query()` and not `$q->posts`.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/31194>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list