Make WordPress Core

Opened 6 years ago

Last modified 4 years ago

#44737 reviewing defect (bug)

WP_Query: in searches post_status should consider exclude_from_search

Reported by: felipeelia's profile felipeelia Owned by: sergeybiryukov's profile SergeyBiryukov
Milestone: Future Release Priority: normal
Severity: normal Version:
Component: Query Keywords: has-patch has-unit-tests needs-dev-note
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 6 years ago.
44737-test.diff (1.2 KB) - added by casepress 6 years ago.
44737-test.2.diff (1.1 KB) - added by casepress 6 years ago.
update test

Download all attachments as: .zip

Change History (12)

@felipeelia
6 years ago

#1 @soulseekah
6 years ago

  • Keywords needs-unit-tests added

@casepress
6 years ago

#2 @casepress
6 years ago

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

@casepress
6 years ago

update test

#3 @SergeyBiryukov
5 years ago

  • Milestone changed from Awaiting Review to 5.3
  • Owner set to SergeyBiryukov
  • Status changed from new to reviewing

This ticket was mentioned in Slack in #core by david.baumwald. View the logs.


5 years ago

#5 @davidbaumwald
5 years ago

  • Keywords needs-dev-note added

This ticket was discussed during 5.3 Bug Scrub 1. Since this possibly alters search results, this should be communicated with a dev note.

Last edited 5 years ago by davidbaumwald (previous) (diff)

This ticket was mentioned in Slack in #core by marybaum. View the logs.


5 years ago

#7 @davidbaumwald
5 years ago

@SergeyBiryukov How do you feel about this one landing in 5.3? Is there anything esle you need to make that happen?

#8 @davidbaumwald
5 years ago

  • Milestone changed from 5.3 to Future Release

With 5.3 RC1 releasing today, this ticket is being moved to Future Release. If any committer feels this can be worked in quickly for 5.3 or can assume ownership in 5.4, feel free to move it back up.

Note: See TracTickets for help on using tickets.