| 1 | Index: wp-includes/taxonomy.php |
|---|
| 2 | =================================================================== |
|---|
| 3 | --- wp-includes/taxonomy.php (revision 17950) |
|---|
| 4 | +++ wp-includes/taxonomy.php (working copy) |
|---|
| 5 | @@ -636,7 +636,26 @@ |
|---|
| 6 | $where = array(); |
|---|
| 7 | $i = 0; |
|---|
| 8 | |
|---|
| 9 | - foreach ( $this->queries as $query ) { |
|---|
| 10 | + // convert AND queries to IN ones for more efficient SQL |
|---|
| 11 | + if ( 'AND' == $this->relation ) { |
|---|
| 12 | + $final_queries = array(); |
|---|
| 13 | + foreach ( $this->queries as $query ) { |
|---|
| 14 | + if ( 'AND' == $query['operator'] && count( $query['terms'] ) <= 10 ) { |
|---|
| 15 | + foreach ( $query['terms'] as $term ) { |
|---|
| 16 | + $final_queries[] = array_merge( $query, array( |
|---|
| 17 | + 'terms' => $term, |
|---|
| 18 | + 'operator' => 'IN' |
|---|
| 19 | + ) ); |
|---|
| 20 | + } |
|---|
| 21 | + } else { |
|---|
| 22 | + $final_queries[] = $query; |
|---|
| 23 | + } |
|---|
| 24 | + } |
|---|
| 25 | + } else { |
|---|
| 26 | + $final_queries = $this->queries; |
|---|
| 27 | + } |
|---|
| 28 | + |
|---|
| 29 | + foreach ( $final_queries as $query ) { |
|---|
| 30 | $this->clean_query( $query ); |
|---|
| 31 | |
|---|
| 32 | if ( is_wp_error( $query ) ) { |
|---|