Ticket #14880: 14880.2.diff
| File 14880.2.diff, 2.3 KB (added by , 15 years ago) |
|---|
-
wp-includes/taxonomy.php
457 457 $taxonomies = (array) $taxonomies; 458 458 459 459 foreach ( $taxonomies as $taxonomy ) { 460 if ( ! taxonomy_exists( $taxonomy ) )460 if ( !taxonomy_exists( $taxonomy ) ) 461 461 return new WP_Error( 'invalid_taxonomy', sprintf( __( 'Invalid Taxonomy: %s' ), $taxonomy ) ); 462 462 } 463 463 … … 530 530 * 'field' string Which term field is being used. Can be 'term_id', 'slug' or 'name' 531 531 * 'operator' string Can be 'IN' and 'NOT IN' 532 532 * 533 * @return array| WP_Error List of matching object_ids; WP_Erroron failure.533 * @return array|bool List of matching object_ids; False on failure. 534 534 */ 535 535 function wp_tax_query( $queries ) { 536 536 global $wpdb; 537 537 538 $sql = array();538 $sql_list = array(); 539 539 foreach ( $queries as $query ) { 540 540 if ( !isset( $query['include_children'] ) ) 541 541 $query['include_children'] = true; 542 542 $query['do_query'] = false; 543 $sql[] = get_objects_in_term( $query['terms'], $query['taxonomy'], $query ); 543 $sql = get_objects_in_term( $query['terms'], $query['taxonomy'], $query ); 544 545 if ( is_wp_error( $sql ) ) 546 continue; 547 548 $sql_list[] = $sql; 544 549 } 545 550 546 if ( 1 == count( $sql) )547 return $wpdb->get_col( $sql[0] );551 if ( empty( $sql_list ) ) 552 return false; 548 553 554 if ( 1 == count( $sql_list ) ) 555 return $wpdb->get_col( $sql_list[0] ); 556 549 557 $r = "SELECT object_id FROM $wpdb->term_relationships WHERE 1=1"; 550 foreach ( $sql as $query )558 foreach ( $sql_list as $query ) 551 559 $r .= " AND object_id IN ($query)"; 552 560 553 561 return $wpdb->get_col( $r ); -
wp-includes/query.php
1940 1940 if ( !empty( $tax_query ) ) { 1941 1941 $this->tax_query = $tax_query; 1942 1942 1943 $where .= " AND $wpdb->posts.ID IN( " . implode( ', ', wp_tax_query( $tax_query ) ) . ")"; 1943 $tax_found_ids = wp_tax_query( $this->tax_query ); 1944 1945 if ( is_array( $tax_found_ids ) ) { 1946 if ( !empty( $tax_found_ids ) ) 1947 $where .= " AND $wpdb->posts.ID IN(" . implode( ',', $tax_found_ids ) . ")"; 1948 else 1949 $where .= " AND 0 = 1"; 1950 } 1944 1951 } 1945 1952 1946 1953 if ( !empty($q['meta_key']) ) {