WordPress.org

Make WordPress Core


Ignore:
Timestamp:
04/05/2007 09:16:02 PM (15 years ago)
Author:
ryan
Message:

Bit twiddling. Add type bitfield to categories table. see #3723

File:
1 edited

Legend:

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

    r5158 r5184  
    788788            continue; // discard
    789789        if ( !$tag_id = category_exists( $tag ) )
    790             $tag_id = wp_create_category( $tag );
     790            $tag_id = wp_create_tag( $tag );
    791791        $tag_ids[] = $tag_id;
    792792    }
     
    838838    foreach ( $all_affected_tags as $tag_id ) {
    839839        $count = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->post2cat, $wpdb->posts WHERE $wpdb->posts.ID=$wpdb->post2cat.post_id AND post_status = 'publish' AND post_type = 'post' AND category_id = '$tag_id' AND rel_type = 'tag'" );
    840         $wpdb->query( "UPDATE $wpdb->categories SET tag_count = '$count' WHERE cat_ID = '$tag_id'" );
     840        $wpdb->query( "UPDATE $wpdb->categories SET tag_count = '$count', type = type | " . TAXONOMY_TAG . " WHERE cat_ID = '$tag_id'" );
    841841        if ( $count == 0 )
    842             $wpdb->query( "UPDATE $wpdb->categories SET tag_count = '-1' WHERE cat_ID = '$tag_id'" );
     842            $wpdb->query( "UPDATE $wpdb->categories SET type = type & ~". TAXONOMY_TAG . " WHERE cat_ID = '$tag_id'" );
    843843        clean_category_cache( $tag_id );
    844844        do_action( 'edit_category', $tag_id );
     
    877877                DELETE FROM $wpdb->post2cat
    878878                WHERE category_id = '$del'
    879                     AND post_id = '$post_ID'
     879                    AND post_id = '$post_ID' AND rel_type = 'category'
    880880                ");
    881881        }
     
    899899    foreach ( $all_affected_cats as $cat_id ) {
    900900        $count = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->post2cat, $wpdb->posts WHERE $wpdb->posts.ID=$wpdb->post2cat.post_id AND post_status = 'publish' AND post_type = 'post' AND category_id = '$cat_id' AND rel_type = 'category'");
    901         $wpdb->query("UPDATE $wpdb->categories SET category_count = '$count' WHERE cat_ID = '$cat_id'");
     901        $wpdb->query("UPDATE $wpdb->categories SET category_count = '$count', type = type | " . TAXONOMY_CATEGORY . " WHERE cat_ID = '$cat_id'");
    902902        clean_category_cache($cat_id);
    903903        do_action('edit_category', $cat_id);
Note: See TracChangeset for help on using the changeset viewer.