WordPress.org

Make WordPress Core

Opened 12 months ago

Last modified 4 months ago

#44737 reviewing defect (bug)

WP_Query: in searches post_status should consider exclude_from_search

Reported by: felipeelia Owned by: SergeyBiryukov
Milestone: 5.3 Priority: normal
Severity: normal Version:
Component: Query Keywords: has-patch has-unit-tests
Focuses: Cc:

Description

When post_status is empty and we are running a search, this code is executed (wp-includes/class-wp-query.php:2446):

// Add public states.
$public_states = get_post_stati( array( 'public' => true ) );
foreach ( (array) $public_states as $state ) {
        if ( 'publish' == $state ) { // Publish is hard-coded above.
                continue;
        }
        $where .= " OR {$wpdb->posts}.post_status = '$state'";
}

That way the exclude_from_search parameter isn't considered.

Attachments (3)

44737.diff (1.1 KB) - added by felipeelia 12 months ago.
44737-test.diff (1.2 KB) - added by casepress 11 months ago.
44737-test.2.diff (1.1 KB) - added by casepress 11 months ago.
update test

Download all attachments as: .zip

Change History (6)

@felipeelia
12 months ago

#1 @soulseekah
11 months ago

  • Keywords needs-unit-tests added

#2 @casepress
11 months ago

  • Keywords has-unit-tests added; needs-unit-tests removed

@casepress
11 months ago

update test

#3 @SergeyBiryukov
4 months ago

  • Milestone changed from Awaiting Review to 5.3
  • Owner set to SergeyBiryukov
  • Status changed from new to reviewing
Note: See TracTickets for help on using tickets.