[wp-trac] [WordPress Trac] #51094: WP_Query.query with invalid post_status will return all

WordPress Trac noreply at wordpress.org
Mon Aug 24 15:29:28 UTC 2020


#51094: WP_Query.query with invalid post_status will return all
--------------------------+------------------------------
 Reporter:  carsonreinke  |       Owner:  (none)
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  Query         |     Version:  trunk
 Severity:  minor         |  Resolution:
 Keywords:                |     Focuses:
--------------------------+------------------------------

Comment (by carsonreinke):

 @kishanjasani Sorry for the confusion, my reference to WooCommerce was
 simply how I came to this area in WordPress.

 The following below seems wrong to me, since instead of returning NOTHING,
 it will return ALL posts:

 {{{#!php
 <?php
 $q = new WP_Query( array( 'post_status' => 'publish' ) );
 $q->found_posts; //All published posts

 $q = new WP_Query( array( 'post_status' => 'fake status' ) );
 $q->found_posts; //Should be zero, instead ALL posts
 }}}

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/51094#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list