Make WordPress Core

Changeset 2966


Ignore:
Timestamp:
10/27/2005 10:04:12 PM (20 years ago)
Author:
ryan
Message:

DB versioning. fixes #1791

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/install.php

    r2945 r2966  
    139139make_db_current_silent();
    140140populate_options();
     141populate_roles();
    141142
    142143$wpdb->query("UPDATE $wpdb->options SET option_value = '$weblog_title' WHERE option_name = 'blogname'");
     
    197198@wp_mail($admin_email, __('New WordPress Blog'), $message, $message_headers);
    198199
    199 upgrade_all();
    200200?>
    201201
  • trunk/wp-admin/upgrade-functions.php

    r2730 r2966  
    55// Functions to be called in install and upgrade scripts
    66function upgrade_all() {
     7    global $wp_current_db_version, $wp_db_version;
     8    $wp_current_db_version = __get_option('db_version');
     9
     10    // We are up-to-date.  Nothing to do.
     11    if ( $wp_db_version == $wp_current_db_version )
     12        return;
     13
     14    // If the version is not set in the DB, try to guess the version.
     15    if ( empty($wp_current_db_version) ) {
     16        $wp_current_db_version = 0;
     17
     18        // If the template option exists, we have 1.5.
     19        $template = __get_option('template');
     20        if ( !empty($template) )
     21            $wp_current_db_version = 2541;
     22    }
     23   
    724    populate_options();
    8     upgrade_100();
    9     upgrade_101();
    10     upgrade_110();
    11     upgrade_130();
    12     upgrade_160();
     25
     26    if ( $wp_current_db_version < 2541 ) {
     27        upgrade_100();
     28        upgrade_101();
     29        upgrade_110();
     30        upgrade_130();
     31    }
     32   
     33    if ( $wp_current_db_version < 2966 )
     34        upgrade_160();
     35
    1336    save_mod_rewrite_rules();
     37   
     38    update_option('db_version', $wp_db_version);
    1439}
    1540
     
    83108
    84109function upgrade_110() {
    85   global $wpdb;
     110    global $wpdb;
    86111   
    87112    // Set user_nicename.
    88     // FIXME: user_nickname is no longer in the user table.  Need to update and
    89     // move this code to where the new usermeta table is setup.
    90 //  $users = $wpdb->get_results("SELECT ID, user_nickname, user_nicename FROM $wpdb->users");
    91 //  foreach ($users as $user) {
    92 //      if ('' == $user->user_nicename) {
    93 //          $newname = sanitize_title($user->user_nickname);
    94 //          $wpdb->query("UPDATE $wpdb->users SET user_nicename = '$newname' WHERE ID = '$user->ID'");
    95 //      }
    96 //  }
     113    $users = $wpdb->get_results("SELECT ID, user_nickname, user_nicename FROM $wpdb->users");
     114    foreach ($users as $user) {
     115        if ('' == $user->user_nicename) {
     116            $newname = sanitize_title($user->user_nickname);
     117            $wpdb->query("UPDATE $wpdb->users SET user_nicename = '$newname' WHERE ID = '$user->ID'");
     118        }
     119    }
    97120
    98121    $users = $wpdb->get_results("SELECT ID, user_pass from $wpdb->users");
     
    219242function upgrade_160() {
    220243    global $wpdb, $table_prefix;
     244   
     245    populate_roles_160();
     246
    221247    $users = $wpdb->get_results("SELECT * FROM $wpdb->users");
    222248    foreach ( $users as $user ) :
  • trunk/wp-admin/upgrade-schema.php

    r2921 r2966  
    223223    add_option('rich_editing', 'true');
    224224
    225     populate_roles();
    226 
    227225    // Delete unused options
    228226    $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');
     
    239237
    240238function populate_roles() {
     239    populate_roles_160();   
     240}
     241
     242function populate_roles_160() {
    241243    global $wp_roles;
    242244
  • trunk/wp-includes/version.php

    r2757 r2966  
    44
    55$wp_version = '1.6-ALPHA-2-still-dont-use';
     6$wp_db_version = 2966;
    67
    78?>
Note: See TracChangeset for help on using the changeset viewer.