Make WordPress Core

Ticket #27266: 27266.diff

File 27266.diff, 1.4 KB (added by swissspidy, 9 years ago)
  • src/wp-includes/query.php

    diff --git src/wp-includes/query.php src/wp-includes/query.php
    index 55f6172..9fe9fe6 100644
    class WP_Query { 
    31163116                                $where .= " AND ($where_status)";
    31173117                        }
    31183118                } elseif ( !$this->is_singular ) {
    3119                         $where .= " AND ($wpdb->posts.post_status = 'publish'";
     3119                        $where .= " AND ($wpdb->posts.post_status = 'publish' OR $wpdb->posts.post_status = 'inherit'";
    31203120
    31213121                        // Add public states.
    31223122                        $public_states = get_post_stati( array('public' => true) );
  • tests/phpunit/tests/query/search.php

    diff --git tests/phpunit/tests/query/search.php tests/phpunit/tests/query/search.php
    index caf862c..4eaff9b 100644
    class Tests_Query_Search extends WP_UnitTestCase { 
    125125
    126126                $this->assertEqualSets( array( $p3 ), $q->posts );
    127127        }
     128
     129        /**
     130         * @ticket 27266
     131         */
     132        function test_search_attachments() {
     133                $post       = self::factory()->post->create( array( 'post_title' => 'Post 1', 'post_type' => 'post' ) );
     134                $page       = self::factory()->post->create( array( 'post_title' => 'Post 2', 'post_type' => 'page' ) );
     135                $attachment = self::factory()->post->create( array( 'post_title' => 'Post 3', 'post_type' => 'attachment' ) );
     136
     137                $q = new WP_Query( array(
     138                        's' => 'Post',
     139                        'fields' => 'ids',
     140                ) );
     141
     142                $this->assertEqualSets( array( $post, $page, $attachment ), $q->posts );
     143        }
    128144}