WordPress.org

Make WordPress Core

Changeset 15734


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

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

Location:
trunk/wp-includes
Files:
2 edited

Legend:

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

    r15731 r15734  
    697697            if ( !isset( $query['include_children'] ) )
    698698                $query['include_children'] = true;
     699
    699700            $query['do_query'] = false;
    700             $sql[] = get_objects_in_term( $query['terms'], $query['taxonomy'], $query );
     701           
     702            $sql_single = get_objects_in_term( $query['terms'], $query['taxonomy'], $query );
     703
     704            if ( empty( $sql_single ) )
     705                return ' AND 0 = 1';
     706
     707            $sql[] = $sql_single;
    701708        }
    702709
  • 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.