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

WordPress Trac noreply at wordpress.org
Mon Aug 11 21:25:05 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                  |  Resolution:
 Keywords:  has-patch dev-feedback  |     Focuses:
Changes (by ebinnion):

 * keywords:  has-patch needs-testing dev-feedback => has-patch dev-feedback


 I have verified that the all query group tests pass, or are skipped. Also,
 I have created a unit test to verify the presence of the bug before and
 the absence of the bug after the suggested patch.

 Here's a screenshot of the unit tests I ran. The first test is without the
 suggested patch. The second test is with the suggested patch.


 Also, here is the unit test I came up with to test querying for a specific
 trashed post.


  * Tests to make sure that trashed posts can be queried when post_status
 is set to 'trash'.
  * @group query
 class Tests_Trashed_Post_Query extends WP_UnitTestCase {

         public function setUp() {

                 $this->post_id = $this->factory->post->create( array(
 'post_title' => 'some-post', 'post_status' => 'trash' ) );

         public function test_query_trash() {
                 $post = new WP_Query(
                                 'p' => $this->post_id,
                                 'post_status' => 'trash'

                 $this->assertCount( 1, $post->posts );


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

More information about the wp-trac mailing list