WordPress.org

Make WordPress Core

Ticket #21606: 21606.diff

File 21606.diff, 2.3 KB (added by nacin, 20 months ago)
  • wp-includes/taxonomy.php

     
    331331                                        ); 
    332332        $args = wp_parse_args($args, $defaults); 
    333333 
    334         if ( strlen( $taxonomy ) > 32 )  
     334        if ( strlen( $taxonomy ) > 32 ) 
    335335                return new WP_Error( 'taxonomy_too_long', __( 'Taxonomies cannot exceed 32 characters in length' ) ); 
    336336 
    337337        if ( false !== $args['query_var'] && !empty($wp) ) { 
     
    14901490                if ( 0 == $term ) 
    14911491                        return 0; 
    14921492                $where = 't.term_id = %d'; 
    1493                 if ( !empty($taxonomy) ) 
    1494                         return $wpdb->get_row( $wpdb->prepare( $tax_select . $where . " AND tt.taxonomy = %s", $term, $taxonomy ), ARRAY_A ); 
    1495                 else 
    1496                         return $wpdb->get_var( $wpdb->prepare( $select . $where, $term ) ); 
     1493                if ( !empty($taxonomy) ) { 
     1494                        if ( $result = $wpdb->get_row( $wpdb->prepare( $tax_select . $where . " AND tt.taxonomy = %s", $term, $taxonomy ), ARRAY_A ) ) 
     1495                                return $result; 
     1496                        return 0; 
     1497                } else { 
     1498                        return (int) $wpdb->get_var( $wpdb->prepare( $select . $where, $term ) ); 
     1499                } 
    14971500        } 
    14981501 
    14991502        $term = trim( stripslashes( $term ) ); 
     
    15201523                if ( $result = $wpdb->get_row( $wpdb->prepare("SELECT tt.term_id, tt.term_taxonomy_id FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy as tt ON tt.term_id = t.term_id WHERE $where AND tt.taxonomy = %s", $where_fields), ARRAY_A) ) 
    15211524                        return $result; 
    15221525 
    1523                 return $wpdb->get_row( $wpdb->prepare("SELECT tt.term_id, tt.term_taxonomy_id FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy as tt ON tt.term_id = t.term_id WHERE $else_where AND tt.taxonomy = %s", $else_where_fields), ARRAY_A); 
     1526                if ( $result = $wpdb->get_row( $wpdb->prepare("SELECT tt.term_id, tt.term_taxonomy_id FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy as tt ON tt.term_id = t.term_id WHERE $else_where AND tt.taxonomy = %s", $else_where_fields), ARRAY_A) ) 
     1527                        return $result; 
     1528 
     1529                return 0; 
    15241530        } 
    15251531 
    15261532        if ( $result = $wpdb->get_var( $wpdb->prepare("SELECT term_id FROM $wpdb->terms as t WHERE $where", $where_fields) ) ) 
    15271533                return $result; 
    15281534 
    1529         return $wpdb->get_var( $wpdb->prepare("SELECT term_id FROM $wpdb->terms as t WHERE $else_where", $else_where_fields) ); 
     1535        return (int) $wpdb->get_var( $wpdb->prepare("SELECT term_id FROM $wpdb->terms as t WHERE $else_where", $else_where_fields) ); 
    15301536} 
    15311537 
    15321538/**