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. git-svn-id: http://svn.automattic.com/wordpress/trunk@18591 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
392ef4c88c
commit
76eb5b8138
|
@ -850,9 +850,10 @@ function &get_term($term, $taxonomy, $output = OBJECT, $filter = 'raw') {
|
|||
} else {
|
||||
if ( is_object($term) )
|
||||
$term = $term->term_id;
|
||||
$term = (int) $term;
|
||||
if ( !$term = (int) $term )
|
||||
return $null;
|
||||
if ( ! $_term = wp_cache_get($term, $taxonomy) ) {
|
||||
$_term = $wpdb->get_row( $wpdb->prepare( "SELECT t.*, tt.* FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy = %s AND t.term_id = %s LIMIT 1", $taxonomy, $term) );
|
||||
$_term = $wpdb->get_row( $wpdb->prepare( "SELECT t.*, tt.* FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy = %s AND t.term_id = %d LIMIT 1", $taxonomy, $term) );
|
||||
if ( ! $_term )
|
||||
return $null;
|
||||
wp_cache_add($term, $_term, $taxonomy);
|
||||
|
|
Loading…
Reference in New Issue