Make WordPress Core

Changeset 18591


Ignore:
Timestamp:
08/24/2011 10:39:52 AM (14 years ago)
Author:
westi
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/taxonomy.php

    r18344 r18591  
    851851        if ( is_object($term) )
    852852            $term = $term->term_id;
    853         $term = (int) $term;
     853        if ( !$term = (int) $term )
     854            return $null;
    854855        if ( ! $_term = wp_cache_get($term, $taxonomy) ) {
    855             $_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) );
     856            $_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) );
    856857            if ( ! $_term )
    857858                return $null;
Note: See TracChangeset for help on using the changeset viewer.