mirror of
https://github.com/WordPress/WordPress.git
synced 2025-01-10 18:37:58 +01:00
Really make slugs unique during upgrade. fixes #4776
git-svn-id: http://svn.automattic.com/wordpress/trunk@5908 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
567bc9d3f1
commit
eb30d086be
@ -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'");
|
||||
|
Loading…
Reference in New Issue
Block a user