Make WordPress Core


Ignore:
Timestamp:
02/12/2006 07:53:23 AM (19 years ago)
Author:
ryan
Message:

Death to trailing tabs. Props Mark J. fixes #2405

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/upgrade-functions.php

    r3514 r3517  
    2121            $wp_current_db_version = 2541;
    2222    }
    23    
     23
    2424    populate_options();
    2525
     
    3030        upgrade_130();
    3131    }
    32    
     32
    3333    if ( $wp_current_db_version < 3308 )
    3434        upgrade_160();
     
    3838
    3939    $wp_rewrite->flush_rules();
    40    
     40
    4141    update_option('db_version', $wp_db_version);
    4242}
     
    5555        }
    5656    }
    57    
     57
    5858    $categories = $wpdb->get_results("SELECT cat_ID, cat_name, category_nicename FROM $wpdb->categories");
    5959    foreach ($categories as $category) {
     
    7878        $catwhere = '';
    7979    endif;
    80    
     80
    8181    $allposts = $wpdb->get_results("SELECT ID, post_category FROM $wpdb->posts WHERE post_category != '0' $catwhere");
    8282    if ($allposts) :
     
    112112function upgrade_110() {
    113113    global $wpdb;
    114    
     114
    115115    // Set user_nicename.
    116116    $users = $wpdb->get_results("SELECT ID, user_nickname, user_nicename FROM $wpdb->users");
     
    281281            $wpdb->query("UPDATE $wpdb->users SET display_name = '$id' WHERE ID = '$user->ID'");
    282282        endif;
    283        
     283
    284284        // FIXME: RESET_CAPS is temporary code to reset roles and caps if flag is set.
    285285        $caps = get_usermeta( $user->ID, $table_prefix . 'capabilities');
     
    289289            update_usermeta( $user->ID, $table_prefix . 'capabilities', array($role => true) );
    290290        }
    291            
     291
    292292    endforeach;
    293293    $old_user_fields = array( 'user_firstname', 'user_lastname', 'user_icq', 'user_aim', 'user_msn', 'user_yim', 'user_idmode', 'user_ip', 'user_domain', 'user_browser', 'user_description', 'user_nickname', 'user_level' );
     
    296296        $wpdb->query("ALTER TABLE $wpdb->users DROP $old");
    297297    $wpdb->show_errors();
    298    
     298
    299299    if ( 0 == $wpdb->get_var("SELECT SUM(category_count) FROM $wpdb->categories") ) { // Create counts
    300300        $categories = $wpdb->get_col("SELECT cat_ID FROM $wpdb->categories");
     
    322322            post_type = ''
    323323            WHERE ID = $object->ID");
    324            
     324
    325325            $meta = get_post_meta($object->ID, 'imagedata', true);
    326326            if ( ! empty($meta['file']) )
     
    336336        // Update status and type.
    337337        $posts = $wpdb->get_results("SELECT ID, post_status FROM $wpdb->posts");
    338    
     338
    339339        if ( ! empty($posts) ) foreach ($posts as $post) {
    340340            $status = $post->post_status;
     
    346346            } else if ( 'attachment' == $status ) {
    347347                $status = 'inherit';
    348                 $type = 'attachment';   
     348                $type = 'attachment';
    349349            }
    350        
     350
    351351            $wpdb->query("UPDATE $wpdb->posts SET post_status = '$status', post_type = '$type' WHERE ID = '$post->ID'");
    352352        }
    353353    }
    354    
     354
    355355    if ( $wp_current_db_version < 3513 ) {
    356         populate_roles_210();   
     356        populate_roles_210();
    357357    }
    358358}
     
    478478function dbDelta($queries, $execute = true) {
    479479    global $wpdb;
    480    
     480
    481481    // Seperate individual queries into an array
    482482    if( !is_array($queries) ) {
     
    484484        if('' == $queries[count($queries) - 1]) array_pop($queries);
    485485    }
    486    
     486
    487487    $cqueries = array(); // Creation Queries
    488488    $iqueries = array(); // Insertion Queries
    489489    $for_update = array();
    490    
     490
    491491    // Create a tablename index for an array ($cqueries) of queries
    492492    foreach($queries as $qry) {
     
    507507            // Unrecognized query type
    508508        }
    509     }   
     509    }
    510510
    511511    // Check to see which tables and fields exist
     
    526526
    527527                //echo "<hr/><pre>\n".print_r(strtolower($table), true).":\n".print_r($cqueries, true)."</pre><hr/>";
    528                
     528
    529529                // For every field line specified in the query
    530530                foreach($flds as $fld) {
     
    532532                    preg_match("|^([^ ]*)|", trim($fld), $fvals);
    533533                    $fieldname = $fvals[1];
    534                    
     534
    535535                    // Verify the found field name
    536536                    $validfield = true;
     
    548548                    }
    549549                    $fld = trim($fld);
    550                    
     550
    551551                    // If it's a valid field, add it to the field array
    552552                    if($validfield) {
     
    554554                    }
    555555                }
    556                
     556
    557557                // Fetch the table column structure from the database
    558558                $tablefields = $wpdb->get_results("DESCRIBE {$table};");
    559                                
     559
    560560                // For every field in the table
    561                 foreach($tablefields as $tablefield) {             
     561                foreach($tablefields as $tablefield) {
    562562                    // If the table field exists in the field array...
    563563                    if(array_key_exists(strtolower($tablefield->Field), $cfields)) {
     
    572572                            $for_update[$table.'.'.$tablefield->Field] = "Changed type of {$table}.{$tablefield->Field} from {$tablefield->Type} to {$fieldtype}";
    573573                        }
    574                        
     574
    575575                        // Get the default value from the array
    576576                            //echo "{$cfields[strtolower($tablefield->Field)]}<br>";
     
    599599                    $for_update[$table.'.'.$fieldname] = 'Added column '.$table.'.'.$fieldname;
    600600                }
    601                
     601
    602602                // Index stuff goes here
    603603                // Fetch the table index structure from the database
    604604                $tableindices = $wpdb->get_results("SHOW INDEX FROM {$table};");
    605                
     605
    606606                if($tableindices) {
    607607                    // Clear the index array
     
    632632                        $index_columns = '';
    633633                        // For each column in the index
    634                         foreach($index_data['columns'] as $column_data) {                   
     634                        foreach($index_data['columns'] as $column_data) {
    635635                            if($index_columns != '') $index_columns .= ',';
    636636                            // Add the field to the column list string
Note: See TracChangeset for help on using the changeset viewer.