Changes from trunk/wp-includes/query.php at r6125 to branches/2.3/wp-includes/query.php at r6253
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.3/wp-includes/query.php
r6125 r6253 933 933 934 934 if ( !empty($q['category__in']) ) { 935 $join = " LEFT JOIN $wpdb->term_relationships ON ($wpdb->posts.ID = $wpdb->term_relationships.object_id) LEFTJOIN $wpdb->term_taxonomy ON ($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id) ";935 $join = " INNER JOIN $wpdb->term_relationships ON ($wpdb->posts.ID = $wpdb->term_relationships.object_id) INNER JOIN $wpdb->term_taxonomy ON ($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id) "; 936 936 $whichcat .= " AND $wpdb->term_taxonomy.taxonomy = 'category' "; 937 937 $include_cats = "'" . implode("', '", $q['category__in']) . "'"; … … 949 949 } 950 950 951 if ( !empty($q['category__and']) ) {952 $count = 0;953 foreach ( $q['category__and'] as $category_and ) {954 $join .= " LEFT JOIN $wpdb->term_relationships AS tr$count ON ($wpdb->posts.ID = tr$count.object_id) LEFT JOIN $wpdb->term_taxonomy AS tt$count ON (tr$count.term_taxonomy_id = tt$count.term_taxonomy_id) ";955 $whichcat .= " AND tt$count.term_id = '$category_and' ";956 $count++;957 }958 }959 960 951 // Category stuff for nice URLs 961 952 if ( '' != $q['category_name'] ) { … … 983 974 $q['cat'] = $reqcat; 984 975 985 $join = " LEFT JOIN $wpdb->term_relationships ON ($wpdb->posts.ID = $wpdb->term_relationships.object_id) LEFTJOIN $wpdb->term_taxonomy ON ($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id) ";976 $join = " INNER JOIN $wpdb->term_relationships ON ($wpdb->posts.ID = $wpdb->term_relationships.object_id) INNER JOIN $wpdb->term_taxonomy ON ($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id) "; 986 977 $whichcat = " AND $wpdb->term_taxonomy.taxonomy = 'category' "; 987 978 $in_cats = array($q['cat']); … … 1025 1016 1026 1017 if ( !empty($q['tag__in']) ) { 1027 $join = " LEFT JOIN $wpdb->term_relationships ON ($wpdb->posts.ID = $wpdb->term_relationships.object_id) LEFTJOIN $wpdb->term_taxonomy ON ($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id) ";1018 $join = " INNER JOIN $wpdb->term_relationships ON ($wpdb->posts.ID = $wpdb->term_relationships.object_id) INNER JOIN $wpdb->term_taxonomy ON ($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id) "; 1028 1019 $whichcat .= " AND $wpdb->term_taxonomy.taxonomy = 'post_tag' "; 1029 1020 $include_tags = "'" . implode("', '", $q['tag__in']) . "'"; … … 1035 1026 1036 1027 if ( !empty($q['tag_slug__in']) ) { 1037 $join = " LEFT JOIN $wpdb->term_relationships ON ($wpdb->posts.ID = $wpdb->term_relationships.object_id) LEFT JOIN $wpdb->term_taxonomy ON ($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id) LEFTJOIN $wpdb->terms ON ($wpdb->term_taxonomy.term_id = $wpdb->terms.term_id) ";1028 $join = " INNER JOIN $wpdb->term_relationships ON ($wpdb->posts.ID = $wpdb->term_relationships.object_id) INNER JOIN $wpdb->term_taxonomy ON ($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id) INNER JOIN $wpdb->terms ON ($wpdb->term_taxonomy.term_id = $wpdb->terms.term_id) "; 1038 1029 $whichcat .= " AND $wpdb->term_taxonomy.taxonomy = 'post_tag' "; 1039 1030 $include_tags = "'" . implode("', '", $q['tag_slug__in']) . "'"; … … 1052 1043 } 1053 1044 1054 if ( !empty($q['tag__and']) ) { 1055 $count = 0; 1056 foreach ( $q['tag__and'] as $tag_and ) { 1057 $join .= " LEFT JOIN $wpdb->term_relationships AS tr$count ON ($wpdb->posts.ID = tr$count.object_id) LEFT JOIN $wpdb->term_taxonomy AS tt$count ON (tr$count.term_taxonomy_id = tt$count.term_taxonomy_id) "; 1058 $whichcat .= " AND tt$count.term_id = '$tag_and' "; 1059 $count++; 1060 } 1061 $reqtag = is_term( $q['tag__and'][0], 'post_tag' ); 1062 if ( !empty($reqtag) ) 1063 $q['tag_id'] = $reqtag['term_id']; 1064 } 1065 1066 if ( !empty($q['tag_slug__and']) ) { 1067 $count = 0; 1068 foreach ( $q['tag_slug__and'] as $tag_and ) { 1069 $join .= " LEFT JOIN $wpdb->term_relationships AS tr$count ON ($wpdb->posts.ID = tr$count.object_id) LEFT JOIN $wpdb->term_taxonomy AS tt$count ON (tr$count.term_taxonomy_id = tt$count.term_taxonomy_id) LEFT JOIN $wpdb->terms AS term$count ON (tt$count.term_id = term$count.term_id) "; 1070 $whichcat .= " AND term$count.slug = '$tag_and' "; 1071 $count++; 1072 } 1073 $reqtag = is_term( $q['tag_slug__and'][0], 'post_tag' ); 1074 if ( !empty($reqtag) ) 1075 $q['tag_id'] = $reqtag['term_id']; 1045 // Tag and slug intersections. 1046 $intersections = array('category__and' => 'category', 'tag__and' => 'post_tag', 'tag_slug__and' => 'post_tag'); 1047 foreach ($intersections as $item => $taxonomy) { 1048 if ( empty($q[$item]) ) continue; 1049 1050 if ( $item != 'category__and' ) { 1051 $reqtag = is_term( $q[$item][0], 'post_tag' ); 1052 if ( !empty($reqtag) ) 1053 $q['tag_id'] = $reqtag['term_id']; 1054 } 1055 1056 $taxonomy_field = $item == 'tag_slug__and' ? 'slug' : 'term_id'; 1057 1058 $q[$item] = array_unique($q[$item]); 1059 $tsql = "SELECT p.ID FROM $wpdb->posts p INNER JOIN $wpdb->term_relationships tr ON (p.ID = tr.object_id) INNER JOIN $wpdb->term_taxonomy tt ON (tr.term_taxonomy_id = tt.term_taxonomy_id) INNER JOIN $wpdb->terms t ON (tt.term_id = t.term_id)"; 1060 $tsql .= " WHERE tt.taxonomy = '$taxonomy' AND t.$taxonomy_field IN ('" . implode("', '", $q[$item]) . "')"; 1061 $tsql .= " GROUP BY p.ID HAVING count(p.ID) = " . count($q[$item]); 1062 1063 $post_ids = $wpdb->get_col($tsql); 1064 1065 if ( count($post_ids) ) 1066 $whichcat .= " AND $wpdb->posts.ID IN (" . implode(', ', $post_ids) . ") "; 1067 else { 1068 $whichcat = " AND 0 = 1"; 1069 break; 1070 } 1076 1071 } 1077 1072
Note: See TracChangeset
for help on using the changeset viewer.