Changeset 5552
- Timestamp:
- 05/26/2007 05:47:20 PM (17 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/upgrade.php
r5542 r5552 579 579 // Convert categories to terms. 580 580 $tt_ids = array(); 581 $categories = $wpdb->get_results("SELECT * FROM $wpdb->categories ");581 $categories = $wpdb->get_results("SELECT * FROM $wpdb->categories ORDER BY cat_ID"); 582 582 foreach ($categories as $category) { 583 583 $term_id = (int) $category->cat_ID; … … 586 586 $slug = $wpdb->escape($category->category_nicename); 587 587 $parent = $wpdb->escape($category->category_parent); 588 $term_group = 0; 589 590 // Associate terms with the same slug in a term group and make slugs unique. 591 if ( $exists = $wpdb->get_results("SELECT term_id, term_group FROM $wpdb->terms WHERE slug = '$slug'") ) { 592 $num = count($exists); 593 $num++; 594 $slug = $slug . "-$num"; 595 $term_group = $exists[0]->term_group; 596 $id = $exists[0]->term_id; 597 if ( empty( $term_group ) ) { 598 $term_group = $wpdb->get_var("SELECT MAX(term_group) FROM $wpdb->terms GROUP BY term_group") + 1; 599 $wpdb->query("UPDATE $wpdb->terms SET term_group = '$term_group' WHERE term_id = '$id'"); 600 } 601 } 602 588 603 $wpdb->query("INSERT INTO $wpdb->terms (term_id, name, slug, term_group) VALUES ('$term_id', '$name', '$slug', '$term_group')"); 589 604 -
trunk/wp-includes/taxonomy.php
r5533 r5552 68 68 } else { 69 69 // The alias isn't in a group, so let's create a new one and firstly add the alias term to it. 70 $term_group = $wpdb->get_var("SELECT MAX( ) term_groupFROM $wpdb->terms GROUP BY term_group") + 1;70 $term_group = $wpdb->get_var("SELECT MAX(term_group) FROM $wpdb->terms GROUP BY term_group") + 1; 71 71 $wpdb->query("UPDATE $wpdb->terms SET term_group = $term_group WHERE term_id = $alias->term_id"); 72 72 }
Note: See TracChangeset
for help on using the changeset viewer.