Make WordPress Core

Changeset 5940


Ignore:
Timestamp:
08/25/2007 04:57:56 PM (17 years ago)
Author:
ryan
Message:

Fix blogroll upgrades from 2.0. fixes #4813

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/upgrade.php

    r5908 r5940  
    607607        // to link_category terms.
    608608        $link_cat_id_map = array();
     609        $default_link_cat = 0;
     610        $tt_ids = array();
    609611        $link_cats = $wpdb->get_results("SELECT cat_id, cat_name FROM " . $wpdb->prefix . 'linkcategories');
    610612        foreach ( $link_cats as $category) {
     
    617619            // Associate terms with the same slug in a term group and make slugs unique.
    618620            if ( $exists = $wpdb->get_results("SELECT term_id, term_group FROM $wpdb->terms WHERE slug = '$slug'") ) {
    619                 $num = count($exists);
    620                 $num++;
    621                 $slug = $slug . "-$num";
    622621                $term_group = $exists[0]->term_group;
    623622                $term_id = $exists[0]->term_id;
    624                 if ( empty( $term_group ) ) {
    625                     $term_group = $wpdb->get_var("SELECT MAX(term_group) FROM $wpdb->terms GROUP BY term_group") + 1;
    626                     $wpdb->query("UPDATE $wpdb->terms SET term_group = '$term_group' WHERE term_id = '$term_id'");
    627                 }
    628623            }
    629624
    630             if ( !empty($term_id) ) {
    631                 $wpdb->query("INSERT INTO $wpdb->terms (term_id, name, slug, term_group) VALUES ('$term_id', '$name', '$slug', '$term_group')");
    632             } else {
     625            if ( empty($term_id) ) {
    633626                $wpdb->query("INSERT INTO $wpdb->terms (name, slug, term_group) VALUES ('$name', '$slug', '$term_group')");
    634627                $term_id = (int) $wpdb->insert_id; 
     
    639632
    640633            $wpdb->query("INSERT INTO $wpdb->term_taxonomy (term_id, taxonomy, description, parent, count) VALUES ('$term_id', 'link_category', '', '0', '0')");
    641             $tt_ids[$term_id][$taxonomy] = (int) $wpdb->insert_id;
     634            $tt_ids[$term_id] = (int) $wpdb->insert_id;
    642635        }
    643636
     
    649642            if ( ! isset($link_cat_id_map[$link->link_category]) )
    650643                continue;
    651             $tt_id = $tt_ids[$term_id]['link_category'];
     644            $term_id = $link_cat_id_map[$link->link_category];
     645            $tt_id = $tt_ids[$term_id];
    652646            if ( empty($tt_id) )
    653647                continue;
Note: See TracChangeset for help on using the changeset viewer.