wp_check_mysql_version();
wp_cache_flush();
+ pre_schema_upgrade();
make_db_current_silent();
upgrade_all();
wp_cache_flush();
if ( $wp_current_db_version < 10360 )
upgrade_280();
+ if ( $wp_current_db_version < 11958 )
+ upgrade_290();
+
maybe_disable_automattic_widgets();
update_option( 'db_version', $wp_db_version );
if ( 1 != $option->dupes ) { // Could this be done in the query?
$limit = $option->dupes - 1;
$dupe_ids = $wpdb->get_col( $wpdb->prepare("SELECT option_id FROM $wpdb->options WHERE option_name = %s LIMIT %d", $option->option_name, $limit) );
- $dupe_ids = join($dupe_ids, ',');
- $wpdb->query("DELETE FROM $wpdb->options WHERE option_id IN ($dupe_ids)");
+ if ( $dupe_ids ) {
+ $dupe_ids = join($dupe_ids, ',');
+ $wpdb->query("DELETE FROM $wpdb->options WHERE option_id IN ($dupe_ids)");
+ }
}
}
populate_roles_280();
}
+/**
+ * Execute changes made in WordPress 2.9.
+ *
+ * @since 2.9.0
+ */
+function upgrade_290() {
+ global $wp_current_db_version;
+
+ if ( $wp_current_db_version < 11958 ) {
+ // Previously, setting depth to 1 would redundantly disable threading, but now 2 is the minimum depth to avoid confusion
+ if ( get_option( 'thread_comments_depth' ) == '1' ) {
+ update_option( 'thread_comments_depth', 2 );
+ update_option( 'thread_comments', 0 );
+ }
+ }
+}
+
// The functions we use to actually do stuff
}
}
+/**
+ * Runs before the schema is upgraded.
+ */
+function pre_schema_upgrade() {
+ global $wp_current_db_version, $wp_db_version, $wpdb;
+
+ // Upgrade versions prior to 2.9
+ if ( $wp_current_db_version < 11557 ) {
+ // Delete duplicate options. Keep the option with the highest option_id.
+ $delete_options = $wpdb->get_col("SELECT o1.option_id FROM $wpdb->options AS o1 JOIN $wpdb->options AS o2 ON o2.option_name = o1.option_name AND o2.option_id > o1.option_id");
+ if ( !empty($delete_options) ) {
+ $delete_options = implode(',', $delete_options);
+ $wpdb->query("DELETE FROM $wpdb->options WHERE option_id IN ($delete_options)");
+ }
+
+ // Drop the old primary key and add the new.
+ $wpdb->query("ALTER TABLE $wpdb->options DROP PRIMARY KEY, ADD PRIMARY KEY(option_id)");
+
+ // Drop the old option_name index. dbDelta() doesn't do the drop.
+ $wpdb->query("ALTER TABLE $wpdb->options DROP INDEX option_name");
+ }
+
+}
+
?>