Make WordPress Core

Opened 13 years ago

Closed 13 years ago

#18076 closed defect (bug) (fixed)

get_term() should never query for term_id = 0

Reported by: mdawaffe's profile mdawaffe Owned by: westi's profile westi
Milestone: 3.3 Priority: normal
Severity: normal Version: 3.2
Component: General Keywords: westi-likes has-patch commit
Focuses: Cc:

Description

In one branch of its logic, get_term() casts the input as an integer and uses that value to lookup the term by term_id (first in the cache, then in the DB). That's unnecessary for 0.

This can happen on every page load via wp_get_nav_menu_object( $string ).

Attached bails on 0.

Attached also switches the prepared query to use %d instead of %s.

Attachments (1)

18076.diff (933 bytes) - added by mdawaffe 13 years ago.

Download all attachments as: .zip

Change History (4)

@mdawaffe
13 years ago

#1 @westi
13 years ago

  • Keywords 3.3-early westi-likes commit added
  • Owner set to westi
  • Status changed from new to accepted

#2 @westi
13 years ago

  • Keywords 3.3-early removed
  • Milestone changed from Awaiting Review to 3.3

#3 @westi
13 years ago

  • Resolution set to fixed
  • Status changed from accepted to closed

In [18591]:

Optimise get_term to not query for term_id = 0. Also improve the prepared query to use %d for the term_id.
Fixes #18076 props mdawaffe.

Note: See TracTickets for help on using tickets.