Ticket #16717: 16717.patch

File 16717.patch, 1.6 KB (added by hakre, 2 years ago)

Port of http://core.trac.wordpress.org/attachment/ticket/16464/16464.2.patch to trunk.

  • wp-includes/query.php

     
    21902190                                if ( !empty( $cat_query ) ) { 
    21912191                                        $cat_query = reset( $cat_query ); 
    21922192                                        $the_cat = get_term_by( $cat_query['field'], $cat_query['terms'][0], 'category' ); 
    2193                                         if ( $the_cat && ! is_wp_error( $the_cat ) ) { 
     2193                                        if ( $the_cat ) { 
    21942194                                                $this->set( 'cat', $the_cat->term_id ); 
    21952195                                                $this->set( 'category_name', $the_cat->slug ); 
    21962196                                        } 
     
    22022202                                if ( !empty( $tag_query ) ) { 
    22032203                                        $tag_query = reset( $tag_query ); 
    22042204                                        $the_tag = get_term_by( $tag_query['field'], $tag_query['terms'][0], 'post_tag' ); 
    2205                                         if ( $the_tag && ! is_wp_error( $the_tag ) ) { 
     2205                                        if ( $the_tag ) { 
    22062206                                                $this->set( 'tag_id', $the_tag->term_id ); 
    22072207                                        } 
    22082208                                        unset( $the_tag ); 
  • wp-includes/taxonomy.php

     
    887887                $value = stripslashes($value); 
    888888                $field = 't.name'; 
    889889        } else { 
    890                 return get_term( (int) $value, $taxonomy, $output, $filter); 
     890                $term = get_term( (int) $value, $taxonomy, $output, $filter); 
     891                if ( is_wp_error( $term ) ) 
     892                        $term = false; 
     893                return $term; 
    891894        } 
    892895 
    893896        $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) );