WordPress.org

Make WordPress Core

Changeset 16512


Ignore:
Timestamp:
11/20/2010 09:28:50 PM (9 years ago)
Author:
scribu
Message:

Fix logic for when excluding a non-existant term. See #12891

Location:
trunk/wp-includes
Files:
2 edited

Legend:

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

    r16511 r16512  
    19481948            $clauses = call_user_func_array( 'get_tax_sql', array( $this->tax_query, $wpdb->posts, 'ID', &$this) );
    19491949
    1950             if ( empty($clauses['join']) && empty($clauses['where']) ) {
    1951                 $where .= ' AND 0 = 1';
    1952             } else {
    1953                 $join .= $clauses['join'];
    1954                 $where .= $clauses['where'];
    1955             }
     1950            $join .= $clauses['join'];
     1951            $where .= $clauses['where'];
    19561952
    19571953            if ( $this->is_tax ) {
  • trunk/wp-includes/taxonomy.php

    r16511 r16512  
    553553            _transform_terms( $terms, $taxonomies, $field, 'term_id' );
    554554
    555             if ( empty( $terms ) )
    556                 continue;
    557 
    558555            $children = array();
    559556            foreach ( $terms as $term ) {
     
    569566        }
    570567
    571         if ( empty( $terms ) )
    572             continue;
    573 
    574         $terms = implode( ',', $terms );
    575 
    576568        if ( 'IN' == $operator ) {
     569            if ( empty( $terms ) )
     570                return array( 'join' => '', 'where' => ' AND 0 = 1');
     571
     572            $terms = implode( ',', $terms );
     573
    577574            $alias = $i ? 'tt' . $i : $wpdb->term_relationships;
    578575
     
    586583        }
    587584        elseif ( 'NOT IN' == $operator ) {
     585            if ( empty( $terms ) )
     586                continue;
     587
     588            $terms = implode( ',', $terms );
     589
    588590            $where .= " AND $primary_table.$primary_id_column NOT IN (
    589591                SELECT object_id
     
    599601function _transform_terms( &$terms, $taxonomies, $field, $resulting_field ) {
    600602    global $wpdb;
     603
     604    if ( empty( $terms ) )
     605        return;
    601606
    602607    if ( $field == $resulting_field )
Note: See TracChangeset for help on using the changeset viewer.