Changeset 11348 for trunk/wp-includes/query.php
- Timestamp:
- 05/15/2009 11:47:28 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/query.php
r11323 r11348 1856 1856 $q['tag_slug__in'][] = $tag; 1857 1857 } 1858 } else if ( preg_match('/[+\s]+/', $q['tag']) ) {1858 } else if ( preg_match('/[+\s]+/', $q['tag']) || !empty($q['cat']) ) { 1859 1859 $tags = preg_split('/[+\s]+/', $q['tag']); 1860 1860 foreach ( (array) $tags as $tag ) { … … 1872 1872 } 1873 1873 1874 if ( !empty($q['tag__in']) ) {1874 if ( !empty($q['tag__in']) && empty($q['cat']) ) { 1875 1875 $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) "; 1876 1876 $whichcat .= " AND $wpdb->term_taxonomy.taxonomy = 'post_tag' "; … … 1882 1882 } 1883 1883 1884 if ( !empty($q['tag_slug__in']) ) {1884 if ( !empty($q['tag_slug__in']) && empty($q['cat']) ) { 1885 1885 $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) "; 1886 1886 $whichcat .= " AND $wpdb->term_taxonomy.taxonomy = 'post_tag' "; … … 1904 1904 1905 1905 // Tag and slug intersections. 1906 $intersections = array('category__and' => 'category', 'tag__and' => 'post_tag', 'tag_slug__and' => 'post_tag'); 1906 $intersections = array('category__and' => 'category', 'tag__and' => 'post_tag', 'tag_slug__and' => 'post_tag', 'tag__in' => 'post_tag', 'tag_slug__in' => 'post_tag'); 1907 $tagin = array('tag__in', 'tag_slug__in'); // These are used to make some exceptions below 1907 1908 foreach ($intersections as $item => $taxonomy) { 1908 1909 if ( empty($q[$item]) ) continue; 1909 1910 if ( in_array($item, $tagin) && empty($q['cat']) ) continue; // We should already have what we need if categories aren't being used 1911 1910 1912 if ( $item != 'category__and' ) { 1911 1913 $reqtag = is_term( $q[$item][0], 'post_tag' ); … … 1914 1916 } 1915 1917 1916 $taxonomy_field = $item == 'tag_slug__and'? 'slug' : 'term_id';1918 $taxonomy_field = $item == ('tag_slug__and' || 'tag_slug__in') ? 'slug' : 'term_id'; 1917 1919 1918 1920 $q[$item] = array_unique($q[$item]); 1919 1921 $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)"; 1920 1922 $tsql .= " WHERE tt.taxonomy = '$taxonomy' AND t.$taxonomy_field IN ('" . implode("', '", $q[$item]) . "')"; 1921 $tsql .= " GROUP BY p.ID HAVING count(p.ID) = " . count($q[$item]); 1922 1923 if ( !in_array($item, $tagin) ) { // This next line is only helpful if we are doing an and relationship 1924 $tsql .= " GROUP BY p.ID HAVING count(p.ID) = " . count($q[$item]); 1925 } 1923 1926 $post_ids = $wpdb->get_col($tsql); 1924 1927
Note: See TracChangeset
for help on using the changeset viewer.