WordPress.org

Make WordPress Core

Changeset 17526


Ignore:
Timestamp:
03/22/2011 08:06:38 PM (9 years ago)
Author:
ryan
Message:

Return false instead of WP_Error from get_term_by() if the term does not exist. Makes fetching a term by id consistent with slug and name. Props hakre. fixes #16464 #16717 for trunk

Location:
trunk/wp-includes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/query.php

    r17506 r17526  
    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 );
     
    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                    }
  • trunk/wp-includes/taxonomy.php

    r17512 r17526  
    890890        $field = 't.name';
    891891    } else {
    892         return get_term( (int) $value, $taxonomy, $output, $filter);
     892        $term = get_term( (int) $value, $taxonomy, $output, $filter);
     893        if ( is_wp_error( $term ) )
     894            $term = false;
     895        return $term;
    893896    }
    894897
Note: See TracChangeset for help on using the changeset viewer.