From 29b90f079dd8c3c2280dc929beae28daade8d39c Mon Sep 17 00:00:00 2001 From: Mark Jaquith Date: Thu, 18 Nov 2010 19:04:47 +0000 Subject: [PATCH] Exclude term exclusions even if they are also inclusions. props foofy, scribu. see #12891 git-svn-id: https://develop.svn.wordpress.org/trunk@16467 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/taxonomy.php | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/wp-includes/taxonomy.php b/wp-includes/taxonomy.php index 3ca891a876..8135cdddda 100644 --- a/wp-includes/taxonomy.php +++ b/wp-includes/taxonomy.php @@ -542,9 +542,6 @@ function get_tax_sql( $tax_query, $primary_table, $primary_id_column ) { return ' AND 0 = 1'; } - if ( !in_array( $operator, array( 'IN', 'NOT IN' ) ) ) - $operator = 'IN'; - $taxonomies = "'" . implode( "', '", $taxonomies ) . "'"; $terms = array_unique( (array) $terms ); @@ -587,16 +584,14 @@ function get_tax_sql( $tax_query, $primary_table, $primary_id_column ) { $i++; } - else { - // NOT IN is very slow for some reason - $where .= " AND $primary_table.$primary_id_column IN ( - SELECT object_id - FROM $wpdb->term_relationships - WHERE term_taxonomy_id $operator ($terms) + elseif ( 'NOT IN' == $operator ) { + $where .= " AND $primary_table.$primary_id_column NOT IN ( + SELECT object_id + FROM $wpdb->term_relationships + WHERE term_taxonomy_id IN ($terms) )"; } } - return compact( 'join', 'where' ); }