Return null if no term queried. fixes #11112

git-svn-id: https://develop.svn.wordpress.org/trunk@12200 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Ryan Boren 2009-11-17 20:51:32 +00:00
parent 56989f4f5c
commit 761aac294c

View File

@ -301,6 +301,7 @@ function get_objects_in_term( $terms, $taxonomies, $args = array() ) {
*/
function &get_term($term, $taxonomy, $output = OBJECT, $filter = 'raw') {
global $wpdb;
$null = null;
if ( empty($term) ) {
$error = new WP_Error('invalid_term', __('Empty Term'));
@ -321,6 +322,8 @@ function &get_term($term, $taxonomy, $output = OBJECT, $filter = 'raw') {
$term = (int) $term;
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) );
if ( ! $_term )
return $null;
wp_cache_add($term, $_term, $taxonomy);
}
}