[wp-trac] [WordPress Trac] #29167: WP_Query bug when querying trashed post

WordPress Trac noreply at wordpress.org
Sun Aug 10 05:31:42 UTC 2014


#29167: WP_Query bug when querying trashed post
--------------------------+-----------------------------
 Reporter:  ebinnion      |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Query         |    Version:  trunk
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 While working with Backbone and polling the server to check for changes to
 posts, I came across what I consider to be a bug.

 It seems that when specifying a post to retrieve, if the post is trashed,
 then the WP_Query object will contain no posts. However, if I was to query
 for trashed posts, a trashed post would show.

 I was able to replicate this bug against the trunk version with the
 following two queries.

 This query will return the trashed post I have in the database. Here is a
 dump of the WP_Query object: http://pastebin.com/zi50DKGt

 {{{
 $trashed = new WP_Query(
         array(
                 'post_status' => 'trash',
         )
 );
 }}}

 This query does not return the trashed post. Here is the dumped WP_Query
 object for the query below: http://pastebin.com/MRf8gYj1

 {{{
 $trashed = new WP_Query(
         array(
                 'p' => 4
         )
 );
 }}}

 Up to this point, I could understand this behavior since it would make
 sense to not show a post that was trashed. But, if the query specifically
 requests the post by ID and specifies that the post_status is trashed, I
 would expect the trashed post to be retrieved. That is not the case.

 {{{
 $trashed = new WP_Query(
         array(
                 'post_status' => 'trash',
                 'p' => 4
         )
 );
 }}}

 Here is the dumped WP_Query object for the above query:
 http://pastebin.com/1PgTg7e2

--
Ticket URL: <https://core.trac.wordpress.org/ticket/29167>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list