Commit eb30d086 authored by ryan's avatar ryan

Really make slugs unique during upgrade. fixes #4776

git-svn-id: http://svn.automattic.com/wordpress/trunk@5908 1a063a9b-81f0-0310-95a4-ce76da25c4cd
parent 567bc9d3
......@@ -538,11 +538,17 @@ function upgrade_230() {
// Associate terms with the same slug in a term group and make slugs unique.
if ( $exists = $wpdb->get_results("SELECT term_id, term_group FROM $wpdb->terms WHERE slug = '$slug'") ) {
$num = count($exists);
$num++;
$slug = $slug . "-$num";
$term_group = $exists[0]->term_group;
$id = $exists[0]->term_id;
$num = 2;
do {
$alt_slug = $slug . "-$num";
$num++;
$slug_check = $wpdb->get_var("SELECT slug FROM $wpdb->terms WHERE slug = '$alt_slug'");
} while ( $slug_check );
$slug = $alt_slug;
if ( empty( $term_group ) ) {
$term_group = $wpdb->get_var("SELECT MAX(term_group) FROM $wpdb->terms GROUP BY term_group") + 1;
$wpdb->query("UPDATE $wpdb->terms SET term_group = '$term_group' WHERE term_id = '$id'");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment