Delete duplicate options.

git-svn-id: http://svn.automattic.com/wordpress/trunk@1975 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
saxmatt 2004-12-18 21:21:50 +00:00
parent fef86c9964
commit 736b9d8bcb
2 changed files with 12 additions and 1 deletions

View File

@ -197,6 +197,16 @@ function upgrade_130() {
$wpdb->query("UPDATE $wpdb->comments SET comment_type='trackback', comment_content = REPLACE(comment_content, '<trackback />', '') WHERE comment_content LIKE '<trackback />%'");
$wpdb->query("UPDATE $wpdb->comments SET comment_type='pingback', comment_content = REPLACE(comment_content, '<pingback />', '') WHERE comment_content LIKE '<pingback />%'");
// Some versions have multiple duplicate option_name rows with the same values
$options = $wpdb->get_results("SELECT option_name, COUNT(option_name) AS dupes FROM `$wpdb->options` GROUP BY option_name");
foreach ( $options as $option ) {
if ( 1 != $option->dupes ) { // Could this be done in the query?
$limit = $option->dupes - 1;
$dupe_ids = $wpdb->get_col("SELECT option_id FROM $wpdb->options WHERE option_name = '$option->option_name' LIMIT $limit");
$dupe_ids = join($dupe_ids, ',');
$wpdb->query("DELETE FROM $wpdb->options WHERE option_id IN ($dupe_ids)");
}
}
}
// The functions we use to actually do stuff

View File

@ -78,7 +78,8 @@ CREATE TABLE $wpdb->options (
option_description tinytext NOT NULL,
option_admin_level int(11) NOT NULL default '1',
autoload enum('yes','no') NOT NULL default 'yes',
PRIMARY KEY (option_id,blog_id,option_name)
PRIMARY KEY (option_id,blog_id,option_name),
KEY option_name (option_name)
);
CREATE TABLE $wpdb->post2cat (
rel_id int(11) NOT NULL auto_increment,