Ticket #21606: 21606.diff
| File 21606.diff, 2.3 KB (added by nacin, 7 months ago) |
|---|
-
wp-includes/taxonomy.php
331 331 ); 332 332 $args = wp_parse_args($args, $defaults); 333 333 334 if ( strlen( $taxonomy ) > 32 ) 334 if ( strlen( $taxonomy ) > 32 ) 335 335 return new WP_Error( 'taxonomy_too_long', __( 'Taxonomies cannot exceed 32 characters in length' ) ); 336 336 337 337 if ( false !== $args['query_var'] && !empty($wp) ) { … … 1490 1490 if ( 0 == $term ) 1491 1491 return 0; 1492 1492 $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 } 1497 1500 } 1498 1501 1499 1502 $term = trim( stripslashes( $term ) ); … … 1520 1523 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) ) 1521 1524 return $result; 1522 1525 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; 1524 1530 } 1525 1531 1526 1532 if ( $result = $wpdb->get_var( $wpdb->prepare("SELECT term_id FROM $wpdb->terms as t WHERE $where", $where_fields) ) ) 1527 1533 return $result; 1528 1534 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) ); 1530 1536 } 1531 1537 1532 1538 /**
