Make WordPress Core


Ignore:
Timestamp:
05/29/2007 04:52:31 PM (18 years ago)
Author:
ryan
Message:

Use taxonomy instead of post2cat. see #4189

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/post.php

    r5586 r5592  
    231231
    232232    $query  = "SELECT DISTINCT * FROM $wpdb->posts ";
    233     $query .= empty( $category ) ? '' : ", $wpdb->post2cat ";
     233    $query .= empty( $category ) ? '' : ", $wpdb->term_relationships, $wpdb->term_taxonomy ";
    234234    $query .= empty( $meta_key ) ? '' : ", $wpdb->postmeta ";
    235235    $query .= " WHERE 1=1 ";
     
    237237    $query .= empty( $post_status ) ? '' : "AND post_status = '$post_status' ";
    238238    $query .= "$exclusions $inclusions " ;
    239     $query .= empty( $category ) ? '' : "AND ($wpdb->posts.ID = $wpdb->post2cat.post_id AND $wpdb->post2cat.category_id = " . $category. ") ";
     239    $query .= empty( $category ) ? '' : "AND ($wpdb->posts.ID = $wpdb->term_relationships.object_id AND $wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id AND $wpdb->term_taxonomy.term_id = " . $category. ") ";
    240240    $query .= empty( $post_parent ) ? '' : "AND $wpdb->posts.post_parent = '$post_parent' ";
    241241    $query .= empty( $meta_key ) | empty($meta_value)  ? '' : " AND ($wpdb->posts.ID = $wpdb->postmeta.post_id AND $wpdb->postmeta.meta_key = '$meta_key' AND $wpdb->postmeta.meta_value = '$meta_value' )";
     
    16961696
    16971697function update_post_category_cache($post_ids) {
    1698     global $wpdb, $category_cache, $tag_cache, $blog_id;
     1698    global $wpdb, $term_cache, $blog_id;
    16991699    // TODO
    17001700    return;
     
    17091709    for ( $i = 0; $i < $count; $i++ ) {
    17101710        $post_id = (int) $post_id_array[ $i ];
    1711         if ( isset( $category_cache[$blog_id][$post_id] ) ) {
     1711        if ( isset( $term_cache[$blog_id][$post_id] ) ) {
    17121712            unset( $post_id_array[ $i ] );
    17131713            continue;
     
    17161716    if ( count( $post_id_array ) == 0 )
    17171717        return;
    1718     $post_id_list = join( ',', $post_id_array ); // with already cached stuff removed
    1719 
    1720     $dogs = $wpdb->get_results("SELECT post_id, category_id, rel_type FROM $wpdb->post2cat WHERE post_id IN ($post_id_list)");
     1718
     1719    $dogs = get_object_terms($post_id_array, array('category', 'post_tag'));
    17211720
    17221721    if ( empty($dogs) )
     
    17241723
    17251724    foreach ($dogs as $catt) {
    1726         if ( 'category' == $catt->rel_type )
    1727             $category_cache[$blog_id][$catt->post_id][$catt->category_id] = &get_category($catt->category_id);
    1728         elseif ( 'tag' == $catt->rel_type )
    1729             $tag_cache[$blog_id][$catt->post_id][$catt->category_id] = &get_category($catt->category_id);
     1725        $term_cache[$blog_id][$catt->post_id][$catt->taxonomy][$catt->category_id] = &get_category($catt->category_id);
    17301726    }
    17311727}
    17321728
    17331729function update_post_caches(&$posts) {
    1734     global $post_cache, $category_cache, $post_meta_cache, $tag_cache;
     1730    global $post_cache;
    17351731    global $wpdb, $blog_id;
    17361732
Note: See TracChangeset for help on using the changeset viewer.