DB versioning. fixes #1791

git-svn-id: http://svn.automattic.com/wordpress/trunk@2966 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2005-10-27 22:04:12 +00:00
parent b8edb9642b
commit 5939e76b0b
4 changed files with 47 additions and 18 deletions

View File

@ -138,6 +138,7 @@ flush();
// Set everything up // Set everything up
make_db_current_silent(); make_db_current_silent();
populate_options(); populate_options();
populate_roles();
$wpdb->query("UPDATE $wpdb->options SET option_value = '$weblog_title' WHERE option_name = 'blogname'"); $wpdb->query("UPDATE $wpdb->options SET option_value = '$weblog_title' WHERE option_name = 'blogname'");
$wpdb->query("UPDATE $wpdb->options SET option_value = '$admin_email' WHERE option_name = 'admin_email'"); $wpdb->query("UPDATE $wpdb->options SET option_value = '$admin_email' WHERE option_name = 'admin_email'");
@ -196,7 +197,6 @@ http://wordpress.org/
@wp_mail($admin_email, __('New WordPress Blog'), $message, $message_headers); @wp_mail($admin_email, __('New WordPress Blog'), $message, $message_headers);
upgrade_all();
?> ?>
<p><em><?php _e('Finished!'); ?></em></p> <p><em><?php _e('Finished!'); ?></em></p>

View File

@ -4,13 +4,38 @@ require_once(ABSPATH . '/wp-admin/admin-functions.php');
require_once(ABSPATH . '/wp-admin/upgrade-schema.php'); require_once(ABSPATH . '/wp-admin/upgrade-schema.php');
// Functions to be called in install and upgrade scripts // Functions to be called in install and upgrade scripts
function upgrade_all() { function upgrade_all() {
global $wp_current_db_version, $wp_db_version;
$wp_current_db_version = __get_option('db_version');
// We are up-to-date. Nothing to do.
if ( $wp_db_version == $wp_current_db_version )
return;
// If the version is not set in the DB, try to guess the version.
if ( empty($wp_current_db_version) ) {
$wp_current_db_version = 0;
// If the template option exists, we have 1.5.
$template = __get_option('template');
if ( !empty($template) )
$wp_current_db_version = 2541;
}
populate_options(); populate_options();
if ( $wp_current_db_version < 2541 ) {
upgrade_100(); upgrade_100();
upgrade_101(); upgrade_101();
upgrade_110(); upgrade_110();
upgrade_130(); upgrade_130();
}
if ( $wp_current_db_version < 2966 )
upgrade_160(); upgrade_160();
save_mod_rewrite_rules(); save_mod_rewrite_rules();
update_option('db_version', $wp_db_version);
} }
function upgrade_100() { function upgrade_100() {
@ -85,15 +110,13 @@ function upgrade_110() {
global $wpdb; global $wpdb;
// Set user_nicename. // Set user_nicename.
// FIXME: user_nickname is no longer in the user table. Need to update and $users = $wpdb->get_results("SELECT ID, user_nickname, user_nicename FROM $wpdb->users");
// move this code to where the new usermeta table is setup. foreach ($users as $user) {
// $users = $wpdb->get_results("SELECT ID, user_nickname, user_nicename FROM $wpdb->users"); if ('' == $user->user_nicename) {
// foreach ($users as $user) { $newname = sanitize_title($user->user_nickname);
// if ('' == $user->user_nicename) { $wpdb->query("UPDATE $wpdb->users SET user_nicename = '$newname' WHERE ID = '$user->ID'");
// $newname = sanitize_title($user->user_nickname); }
// $wpdb->query("UPDATE $wpdb->users SET user_nicename = '$newname' WHERE ID = '$user->ID'"); }
// }
// }
$users = $wpdb->get_results("SELECT ID, user_pass from $wpdb->users"); $users = $wpdb->get_results("SELECT ID, user_pass from $wpdb->users");
foreach ($users as $row) { foreach ($users as $row) {
@ -218,6 +241,9 @@ function upgrade_130() {
function upgrade_160() { function upgrade_160() {
global $wpdb, $table_prefix; global $wpdb, $table_prefix;
populate_roles_160();
$users = $wpdb->get_results("SELECT * FROM $wpdb->users"); $users = $wpdb->get_results("SELECT * FROM $wpdb->users");
foreach ( $users as $user ) : foreach ( $users as $user ) :
if ( !empty( $user->user_firstname ) ) if ( !empty( $user->user_firstname ) )

View File

@ -222,8 +222,6 @@ function populate_options() {
add_option('default_role', 'inactive'); add_option('default_role', 'inactive');
add_option('rich_editing', 'true'); add_option('rich_editing', 'true');
populate_roles();
// Delete unused options // Delete unused options
$unusedoptions = array ('blodotgsping_url', 'bodyterminator', 'emailtestonly', 'phoneemail_separator', 'smilies_directory', 'subjectprefix', 'use_bbcode', 'use_blodotgsping', 'use_phoneemail', 'use_quicktags', 'use_weblogsping', 'weblogs_cache_file', 'use_preview', 'use_htmltrans', 'smilies_directory', 'fileupload_allowedusers', 'use_phoneemail', 'default_post_status', 'default_post_category', 'archive_mode', 'time_difference', 'links_minadminlevel', 'links_use_adminlevels', 'links_rating_type', 'links_rating_char', 'links_rating_ignore_zero', 'links_rating_single_image', 'links_rating_image0', 'links_rating_image1', 'links_rating_image2', 'links_rating_image3', 'links_rating_image4', 'links_rating_image5', 'links_rating_image6', 'links_rating_image7', 'links_rating_image8', 'links_rating_image9', 'weblogs_cacheminutes', 'comment_allowed_tags', 'search_engine_friendly_urls', 'default_geourl_lat', 'default_geourl_lon', 'use_default_geourl', 'weblogs_xml_url', 'new_users_can_blog'); $unusedoptions = array ('blodotgsping_url', 'bodyterminator', 'emailtestonly', 'phoneemail_separator', 'smilies_directory', 'subjectprefix', 'use_bbcode', 'use_blodotgsping', 'use_phoneemail', 'use_quicktags', 'use_weblogsping', 'weblogs_cache_file', 'use_preview', 'use_htmltrans', 'smilies_directory', 'fileupload_allowedusers', 'use_phoneemail', 'default_post_status', 'default_post_category', 'archive_mode', 'time_difference', 'links_minadminlevel', 'links_use_adminlevels', 'links_rating_type', 'links_rating_char', 'links_rating_ignore_zero', 'links_rating_single_image', 'links_rating_image0', 'links_rating_image1', 'links_rating_image2', 'links_rating_image3', 'links_rating_image4', 'links_rating_image5', 'links_rating_image6', 'links_rating_image7', 'links_rating_image8', 'links_rating_image9', 'weblogs_cacheminutes', 'comment_allowed_tags', 'search_engine_friendly_urls', 'default_geourl_lat', 'default_geourl_lon', 'use_default_geourl', 'weblogs_xml_url', 'new_users_can_blog');
foreach ($unusedoptions as $option) : foreach ($unusedoptions as $option) :
@ -238,6 +236,10 @@ function populate_options() {
} }
function populate_roles() { function populate_roles() {
populate_roles_160();
}
function populate_roles_160() {
global $wp_roles; global $wp_roles;
// Add roles // Add roles

View File

@ -3,5 +3,6 @@
// This just holds the version number, in a separate file so we can bump it without cluttering the SVN // This just holds the version number, in a separate file so we can bump it without cluttering the SVN
$wp_version = '1.6-ALPHA-2-still-dont-use'; $wp_version = '1.6-ALPHA-2-still-dont-use';
$wp_db_version = 2966;
?> ?>