WordPress.org

Make WordPress Core

Opened 3 years ago

Closed 2 years ago

Last modified 2 years ago

#18364 closed defect (bug) (fixed)

Don't compute in_search_post_types if we're not going to use it

Reported by: mitchoyoshitaka Owned by: ryan
Milestone: 3.3 Priority: normal
Severity: trivial Version:
Component: Performance Keywords: has-patch
Focuses: Cc:

Description

In WP_Query::get_posts(), we call get_post_types( array('exclude_from_search' => false) ) which we store as $in_search_post_types, but we only actually use it if ( 'any' == $post_type ). The result is not used anywhere else. We should move this into the conditional.

Attachments (1)

18364.diff (1.0 KB) - added by mitchoyoshitaka 3 years ago.

Download all attachments as: .zip

Change History (9)

mitchoyoshitaka3 years ago

comment:1 scribu3 years ago

  • Milestone changed from Awaiting Review to 3.3

comment:2 mitchoyoshitaka3 years ago

  • Keywords has-patch added

comment:3 mitchoyoshitaka3 years ago

Wait, just noticed that this logic here might in fact have a flaw: if there are no post types which have exclude_from_search = false, then magically *all* post types will be checked? Am I reading this right? In that case, shouldn't we just immediately return no results?

Obviously, this wouldn't be an issue except in a very customized setup where all post types have exclude_from_search = true, but still... thoughts anyone?

comment:4 ryan2 years ago

  • Owner set to ryan
  • Resolution set to fixed
  • Status changed from new to closed

In [19078]:

Compute in_search_post_types only when needed. Props mitchoyoshitaka. fixes #18364

comment:5 follow-up: nacin2 years ago

mitcho, your comment sounds like it is worthy of a new ticket.

comment:6 in reply to: ↑ 5 mitchoyoshitaka2 years ago

Replying to nacin:

mitcho, your comment sounds like it is worthy of a new ticket.

#19198 opened.

comment:7 kawauso2 years ago

$exclude_post_types is now unused.

comment:8 nacin2 years ago

In [19216]:

Remove unused variable. props kawauso, see #18364.

Note: See TracTickets for help on using tickets.