Opened 12 years ago
Closed 12 years ago
#31194 closed defect (bug) (fixed)
WP_Query's 'fields' => 'ids' still returns an array of strings
| Reported by: | SergeyBiryukov | Owned by: | SergeyBiryukov |
|---|---|---|---|
| Priority: | normal | Milestone: | 4.2 |
| Component: | Query | Version: | 3.9 |
| Severity: | normal | Keywords: | has-patch commit |
| Cc: | Focuses: |
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.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
Patch fixes it for me, and tests pass.