Changeset 6206

Show
Ignore:
Timestamp:
10/08/07 22:39:20 (1 year ago)
Author:
ryan
Message:

Add some cache clearing to cat to tag converter.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/wp-admin/import/wp-cat2tag.php

    r6147 r6206  
    141141                        if ( !$wpdb->get_var("SELECT object_id FROM $wpdb->term_relationships WHERE object_id = '$post' AND term_taxonomy_id = '$id'") )                         
    142142                            $wpdb->query("INSERT INTO $wpdb->term_relationships (object_id, term_taxonomy_id) VALUES ('$post', '$id')"); 
     143                        clean_post_cache($post); 
    143144                    } 
    144145                } else { 
     146                    $tt_ids = $wpdb->get_col("SELECT term_taxonomy_id FROM $wpdb->term_taxonomy WHERE term_id = '{$category->term_id}' AND taxonomy = 'category'"); 
     147                    if ( $tt_ids ) { 
     148                        $posts = $wpdb->get_col("SELECT object_id FROM $wpdb->term_relationships WHERE term_taxonomy_id IN (" . join(',', $tt_ids) . ") GROUP BY object_id"); 
     149                        foreach ( (array) $posts as $post ) 
     150                            clean_post_cache($post); 
     151                    } 
     152 
    145153                    // Change the category to a tag. 
    146154                    $wpdb->query("UPDATE $wpdb->term_taxonomy SET taxonomy = 'post_tag' WHERE term_id = '{$category->term_id}' AND taxonomy = 'category'"); 
     155 
     156                    $terms = $wpdb->get_col("SELECT term_id FROM $wpdb->term_taxonomy WHERE parent = '{$category->term_id}' AND taxonomy = 'category'"); 
     157                    foreach ( (array) $terms as $term ) 
     158                        clean_category_cache($term); 
    147159 
    148160                    // Set all parents to 0 (root-level) if their parent was the converted tag