Make WordPress Core

Opened 13 years ago

Closed 13 years ago

Last modified 12 years ago

#27252 closed defect (bug) (fixed)

WP_Query's "fields" => "ids" should return an array of integers

Reported by: danielbachhuber Owned by: wonderboymusic
Priority: normal Milestone: 3.9
Component: Query Version:
Severity: normal Keywords: has-patch dev-feedback
Cc: Focuses:

Description

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.

The current, latter behavior causes a subsequent WP_Query with post__in to fail because it's being passed an array of strings.

Attachments (1)

27252.1.diff​ (3.4 KB ) - added by danielbachhuber 13 years ago.
Cast returned post IDs as integers

Download all attachments as: .zip

Change History (6)

@danielbachhuber
13 years ago

Cast returned post IDs as integers

This ticket was mentioned in IRC in #wordpress-dev by wonderboymusic. ​View the logs.


13 years ago

#2 @nacin
13 years ago

I'm all for this but post__in appears to accept an array of numeric strings fine:

$post__in = implode(',', array_map( 'absint', $q['post__in'] ));

#3 @wonderboymusic
13 years ago

  • Owner set to wonderboymusic
  • Resolution → fixed
  • Status new → closed

In 27686:

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.

#5 @SergeyBiryukov
12 years ago

In 31324:

When using WP_Query's 'fields' => 'ids' (or 'fields' => 'id=>parent'), make sure the returned result is always an array of integers.

fixes #31194. see #27252.

Note: See TracTickets for help on using tickets.