Return null if no term queried. fixes #11112

git-svn-id: http://svn.automattic.com/wordpress/trunk@12200 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2009-11-17 20:51:32 +00:00
parent cdf11d3479
commit 4b8a5274af
1 changed files with 3 additions and 0 deletions

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);
}
}