Make WordPress Core

Opened 13 years ago

Closed 13 years ago

#19938 closed defect (bug) (wontfix)

Setting fields as ids or id=>parent does not setup post/count properties

Reported by: ejdanderson's profile ejdanderson Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.0
Component: Query Keywords:
Focuses: Cc:

Description

This may be intentional. But consider the following

$query = new WP_Query(array('fields' => 'ids'));
if ($query->have_posts() || $query->post_count || $query->post || $query->current_post != -1) {
   //do something
} 

The code that sets all these properties is never fired when getting the posts, regardless of what is returned.
The same happens for array('fields' => 'id=>parent');

Is this intentional? I can see reasons on both sides of this.

Perhaps at the very least, the 'the_posts' filter needs to be run when these arguments are passed

Change History (1)

#1 @scribu
13 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to wontfix
  • Status changed from new to closed

It is intentional, to prevent backwards compatibility woes.

For example, calling 'the_posts' filter would probably break a lot of plugins which expect objects, not integers.

Also, instead of $query->have_posts(), just use !empty( $query->posts ).

Note: See TracTickets for help on using tickets.