Changeset 5940
- Timestamp:
- 08/25/2007 04:57:56 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/upgrade.php
r5908 r5940 607 607 // to link_category terms. 608 608 $link_cat_id_map = array(); 609 $default_link_cat = 0; 610 $tt_ids = array(); 609 611 $link_cats = $wpdb->get_results("SELECT cat_id, cat_name FROM " . $wpdb->prefix . 'linkcategories'); 610 612 foreach ( $link_cats as $category) { … … 617 619 // Associate terms with the same slug in a term group and make slugs unique. 618 620 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";622 621 $term_group = $exists[0]->term_group; 623 622 $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 }628 623 } 629 624 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) ) { 633 626 $wpdb->query("INSERT INTO $wpdb->terms (name, slug, term_group) VALUES ('$name', '$slug', '$term_group')"); 634 627 $term_id = (int) $wpdb->insert_id; … … 639 632 640 633 $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; 642 635 } 643 636 … … 649 642 if ( ! isset($link_cat_id_map[$link->link_category]) ) 650 643 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]; 652 646 if ( empty($tt_id) ) 653 647 continue;
Note: See TracChangeset
for help on using the changeset viewer.