Make WordPress Core


Ignore:
Timestamp:
10/06/2010 12:06:23 PM (16 years ago)
Author:
scribu
Message:

Prevent db error when dealing with unexistant parent term. See #12891

File:
1 edited

Legend:

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

    r15732 r15734  
    467467        }
    468468
    469         $terms = array_unique( (array) $terms );
    470         if ( empty($terms) )
    471                 continue;
    472 
    473469        if ( !in_array( $field, array( 'term_id', 'slug', 'name' ) ) )
    474470                $field = 'term_id';
     
    476472        if ( !in_array( $operator, array( 'IN', 'NOT IN' ) ) )
    477473                $operator = 'IN';
     474
     475        $terms = array_unique( (array) $terms );
    478476
    479477        if ( is_taxonomy_hierarchical( $taxonomy ) && $include_children ) {
     
    493491        }
    494492
     493        if ( empty( $terms ) )
     494                return $do_query ? array() : '';
     495
    495496        $taxonomies = "'" . implode( "', '", $taxonomies ) . "'";
    496497
     
    528529        }
    529530
    530         if ( !$do_query )
    531                 return $sql;
    532 
    533         return $wpdb->get_col( $sql ); 
     531        return $do_query ? $wpdb->get_col( $sql ) : $sql;
    534532}
    535533
Note: See TracChangeset for help on using the changeset viewer.