WordPress.org

Make WordPress Core

Ticket #5433: 5433.diff

File 5433.diff, 4.0 KB (added by Otto42, 14 years ago)

Fix - First attempt

  • wp-includes/query.php

     
    969969                }
    970970
    971971                if ( !empty($q['category__in']) ) {
    972                         $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) ";
    973                         $whichcat .= " AND $wpdb->term_taxonomy.taxonomy = 'category' ";
    974972                        $include_cats = "'" . implode("', '", $q['category__in']) . "'";
    975                         $whichcat .= " AND $wpdb->term_taxonomy.term_id IN ($include_cats) ";
     973                        $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 AND $wpdb->term_taxonomy.taxonomy = 'category' AND $wpdb->term_taxonomy.term_id IN ($include_cats)) ";
    976974                }
    977975
    978976                if ( !empty($q['category__not_in']) ) {
     
    10101008
    10111009                        $q['cat'] = $reqcat;
    10121010
    1013                         $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) ";
    1014                         $whichcat = " AND $wpdb->term_taxonomy.taxonomy = 'category' ";
    10151011                        $in_cats = array($q['cat']);
    10161012                        $in_cats = array_merge($in_cats, get_term_children($q['cat'], 'category'));
    10171013                        $in_cats = "'" . implode("', '", $in_cats) . "'";
    1018                         $whichcat .= "AND $wpdb->term_taxonomy.term_id IN ($in_cats)";
     1014                        $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 AND $wpdb->term_taxonomy.taxonomy = 'category' AND $wpdb->term_taxonomy.term_id IN ($in_cats))";
    10191015                        $groupby = "{$wpdb->posts}.ID";
    10201016                }
    10211017
     
    10451041                }
    10461042
    10471043                if ( !empty($q['tag__in']) ) {
    1048                         $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) ";
    1049                         $whichcat .= " AND $wpdb->term_taxonomy.taxonomy = 'post_tag' ";
    10501044                        $include_tags = "'" . implode("', '", $q['tag__in']) . "'";
    1051                         $whichcat .= " AND $wpdb->term_taxonomy.term_id IN ($include_tags) ";
     1045                        $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 AND $wpdb->term_taxonomy.taxonomy = 'post_tag' AND $wpdb->term_taxonomy.term_id IN ($include_tags)) ";
    10521046                        $reqtag = is_term( $q['tag__in'][0], 'post_tag' );
    10531047                        if ( !empty($reqtag) )
    10541048                                $q['tag_id'] = $reqtag['term_id'];
    10551049                }
    10561050
    10571051                if ( !empty($q['tag_slug__in']) ) {
    1058                         $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) ";
    1059                         $whichcat .= " AND $wpdb->term_taxonomy.taxonomy = 'post_tag' ";
    10601052                        $include_tags = "'" . implode("', '", $q['tag_slug__in']) . "'";
    1061                         $whichcat .= " AND $wpdb->terms.slug IN ($include_tags) ";
     1053                        $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 AND $wpdb->term_taxonomy.taxonomy = 'post_tag' AND $wpdb->terms.slug IN ($include_tags)) ";
    10621054                        $reqtag = is_term( $q['tag_slug__in'][0], 'post_tag' );
    10631055                        if ( !empty($reqtag) )
    10641056                                $q['tag_id'] = $reqtag['term_id'];