Make WordPress Core

Opened 13 years ago

Closed 12 years ago

Last modified 12 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's profile mitchoyoshitaka Owned by: ryan's profile 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 13 years ago.

Download all attachments as: .zip

Change History (9)

#1 @scribu
13 years ago

  • Milestone changed from Awaiting Review to 3.3

#2 @mitchoyoshitaka
13 years ago

  • Keywords has-patch added

#3 @mitchoyoshitaka
13 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?

#4 @ryan
12 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

#5 follow-up: @nacin
12 years ago

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

#6 in reply to: ↑ 5 @mitchoyoshitaka
12 years ago

Replying to nacin:

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

#19198 opened.

#7 @kawauso
12 years ago

$exclude_post_types is now unused.

#8 @nacin
12 years ago

In [19216]:

Remove unused variable. props kawauso, see #18364.

Note: See TracTickets for help on using tickets.