Opened 10 years ago
Closed 10 years ago
#31194 closed defect (bug) (fixed)
WP_Query's 'fields' => 'ids' still returns an array of strings
Reported by: | SergeyBiryukov | Owned by: | SergeyBiryukov |
---|---|---|---|
Milestone: | 4.2 | Priority: | normal |
Severity: | normal | Version: | 3.9 |
Component: | Query | Keywords: | has-patch commit |
Focuses: | Cc: |
Description
#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
.
Attachments (1)
Change History (5)
Note: See
TracTickets for help on using
tickets.
Patch fixes it for me, and tests pass.