Ticket #13170: 13170.diff
| File 13170.diff, 1.2 KB (added by ryan, 3 years ago) |
|---|
-
wp-includes/taxonomy.php
463 463 if ( ! $_term ) 464 464 return $null; 465 465 wp_cache_add($term, $_term, $taxonomy); 466 wp_cache_add($_term->slug, $term, "{$taxonomy}_slugs"); 466 467 } 467 468 } 468 469 … … 521 522 $value = sanitize_title($value); 522 523 if ( empty($value) ) 523 524 return false; 525 if ( $id = wp_cache_get($value, "{$taxonomy}_slugs") ) 526 return get_term( (int) $id, $taxonomy, $output, $filter); 524 527 } else if ( 'name' == $field ) { 525 528 // Assume already escaped 526 529 $value = stripslashes($value); 527 530 $field = 't.name'; 528 531 } else { 529 $field = 't.term_id'; 530 $value = (int) $value; 532 return get_term( (int) $value, $taxonomy, $output, $filter); 531 533 } 532 534 533 535 $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 $field = %s LIMIT 1", $taxonomy, $value) ); … … 535 537 return false; 536 538 537 539 wp_cache_add($term->term_id, $term, $taxonomy); 540 wp_cache_add($term->slug, $term->term_id, "{$taxonomy}_slugs"); 538 541 539 542 $term = sanitize_term($term, $taxonomy, $filter); 540 543
