DB versioning. fixes #1791
git-svn-id: https://develop.svn.wordpress.org/trunk@2966 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
6b31c735f4
commit
305c29d4e1
|
@ -138,6 +138,7 @@ flush();
|
|||
// Set everything up
|
||||
make_db_current_silent();
|
||||
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 = '$admin_email' WHERE option_name = 'admin_email'");
|
||||
|
@ -196,7 +197,6 @@ http://wordpress.org/
|
|||
|
||||
@wp_mail($admin_email, __('New WordPress Blog'), $message, $message_headers);
|
||||
|
||||
upgrade_all();
|
||||
?>
|
||||
|
||||
<p><em><?php _e('Finished!'); ?></em></p>
|
||||
|
|
|
@ -4,13 +4,38 @@ require_once(ABSPATH . '/wp-admin/admin-functions.php');
|
|||
require_once(ABSPATH . '/wp-admin/upgrade-schema.php');
|
||||
// Functions to be called in install and upgrade scripts
|
||||
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();
|
||||
|
||||
if ( $wp_current_db_version < 2541 ) {
|
||||
upgrade_100();
|
||||
upgrade_101();
|
||||
upgrade_110();
|
||||
upgrade_130();
|
||||
}
|
||||
|
||||
if ( $wp_current_db_version < 2966 )
|
||||
upgrade_160();
|
||||
|
||||
save_mod_rewrite_rules();
|
||||
|
||||
update_option('db_version', $wp_db_version);
|
||||
}
|
||||
|
||||
function upgrade_100() {
|
||||
|
@ -85,15 +110,13 @@ function upgrade_110() {
|
|||
global $wpdb;
|
||||
|
||||
// Set user_nicename.
|
||||
// FIXME: user_nickname is no longer in the user table. Need to update and
|
||||
// move this code to where the new usermeta table is setup.
|
||||
// $users = $wpdb->get_results("SELECT ID, user_nickname, user_nicename FROM $wpdb->users");
|
||||
// foreach ($users as $user) {
|
||||
// if ('' == $user->user_nicename) {
|
||||
// $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_nickname, user_nicename FROM $wpdb->users");
|
||||
foreach ($users as $user) {
|
||||
if ('' == $user->user_nicename) {
|
||||
$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");
|
||||
foreach ($users as $row) {
|
||||
|
@ -218,6 +241,9 @@ function upgrade_130() {
|
|||
|
||||
function upgrade_160() {
|
||||
global $wpdb, $table_prefix;
|
||||
|
||||
populate_roles_160();
|
||||
|
||||
$users = $wpdb->get_results("SELECT * FROM $wpdb->users");
|
||||
foreach ( $users as $user ) :
|
||||
if ( !empty( $user->user_firstname ) )
|
||||
|
|
|
@ -222,8 +222,6 @@ function populate_options() {
|
|||
add_option('default_role', 'inactive');
|
||||
add_option('rich_editing', 'true');
|
||||
|
||||
populate_roles();
|
||||
|
||||
// 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');
|
||||
foreach ($unusedoptions as $option) :
|
||||
|
@ -238,6 +236,10 @@ function populate_options() {
|
|||
}
|
||||
|
||||
function populate_roles() {
|
||||
populate_roles_160();
|
||||
}
|
||||
|
||||
function populate_roles_160() {
|
||||
global $wp_roles;
|
||||
|
||||
// Add roles
|
||||
|
|
|
@ -3,5 +3,6 @@
|
|||
// 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_db_version = 2966;
|
||||
|
||||
?>
|
Loading…
Reference in New Issue