Make WordPress Core


Ignore:
Timestamp:
11/19/2006 07:56:05 AM (18 years ago)
Author:
ryan
Message:

Remove trailing spaces and convert spaces to tabs. Props Nazgul. fixes #986

File:
1 edited

Legend:

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

    r4366 r4495  
    121121"), $blog_url, $name, $password);
    122122
    123     @wp_mail($email, __('New WordPress Blog'), $message, $message_headers); 
     123    @wp_mail($email, __('New WordPress Blog'), $message, $message_headers);
    124124}
    125125endif;
     
    138138    make_db_current_silent();
    139139    upgrade_all();
    140     wp_cache_flush();   
     140    wp_cache_flush();
    141141}
    142142endif;
     
    188188    if ($posts) {
    189189        foreach($posts as $post) {
    190             if ('' == $post->post_name) { 
     190            if ('' == $post->post_name) {
    191191                $newtitle = sanitize_title($post->post_title);
    192192                $wpdb->query("UPDATE $wpdb->posts SET post_name = '$newtitle' WHERE ID = '$post->ID'");
     
    197197    $categories = $wpdb->get_results("SELECT cat_ID, cat_name, category_nicename FROM $wpdb->categories");
    198198    foreach ($categories as $category) {
    199         if ('' == $category->category_nicename) { 
     199        if ('' == $category->category_nicename) {
    200200            $newtitle = sanitize_title($category->cat_name);
    201201            $wpdb->query("UPDATE $wpdb->categories SET category_nicename = '$newtitle' WHERE cat_ID = '$category->cat_ID'");
     
    252252    global $wpdb;
    253253
    254     // Set user_nicename.
     254    // Set user_nicename.
    255255    $users = $wpdb->get_results("SELECT ID, user_nickname, user_nicename FROM $wpdb->users");
    256     foreach ($users as $user) {
    257         if ('' == $user->user_nicename) {
    258             $newname = sanitize_title($user->user_nickname);
    259             $wpdb->query("UPDATE $wpdb->users SET user_nicename = '$newname' WHERE ID = '$user->ID'");
    260         }
    261     }
     256    foreach ($users as $user) {
     257        if ('' == $user->user_nicename) {
     258            $newname = sanitize_title($user->user_nickname);
     259            $wpdb->query("UPDATE $wpdb->users SET user_nicename = '$newname' WHERE ID = '$user->ID'");
     260        }
     261    }
    262262
    263263    $users = $wpdb->get_results("SELECT ID, user_pass from $wpdb->users");
    264264    foreach ($users as $row) {
    265265        if (!preg_match('/^[A-Fa-f0-9]{32}$/', $row->user_pass)) {
    266                $wpdb->query('UPDATE '.$wpdb->users.' SET user_pass = MD5(\''.$row->user_pass.'\') WHERE ID = \''.$row->ID.'\'');
     266            $wpdb->query('UPDATE '.$wpdb->users.' SET user_pass = MD5(\''.$row->user_pass.'\') WHERE ID = \''.$row->ID.'\'');
    267267        }
    268268    }
     
    306306
    307307function upgrade_130() {
    308     global $wpdb;
    309 
    310     // Remove extraneous backslashes.
     308    global $wpdb;
     309
     310    // Remove extraneous backslashes.
    311311    $posts = $wpdb->get_results("SELECT ID, post_title, post_content, post_excerpt, guid, post_date, post_name, post_status, post_author FROM $wpdb->posts");
    312312    if ($posts) {
    313313        foreach($posts as $post) {
    314             $post_content = addslashes(deslash($post->post_content));
    315             $post_title = addslashes(deslash($post->post_title));
    316             $post_excerpt = addslashes(deslash($post->post_excerpt));
     314            $post_content = addslashes(deslash($post->post_content));
     315            $post_title = addslashes(deslash($post->post_title));
     316            $post_excerpt = addslashes(deslash($post->post_excerpt));
    317317            if ( empty($post->guid) )
    318318                $guid = get_permalink($post->ID);
     
    320320                $guid = $post->guid;
    321321
    322             $wpdb->query("UPDATE $wpdb->posts SET post_title = '$post_title', post_content = '$post_content', post_excerpt = '$post_excerpt', guid = '$guid' WHERE ID = '$post->ID'");
    323         }
    324     }
    325 
    326     // Remove extraneous backslashes.
     322            $wpdb->query("UPDATE $wpdb->posts SET post_title = '$post_title', post_content = '$post_content', post_excerpt = '$post_excerpt', guid = '$guid' WHERE ID = '$post->ID'");
     323        }
     324    }
     325
     326    // Remove extraneous backslashes.
    327327    $comments = $wpdb->get_results("SELECT comment_ID, comment_author, comment_content FROM $wpdb->comments");
    328328    if ($comments) {
    329329        foreach($comments as $comment) {
    330             $comment_content = addslashes(deslash($comment->comment_content));
    331             $comment_author = addslashes(deslash($comment->comment_author));
    332             $wpdb->query("UPDATE $wpdb->comments SET comment_content = '$comment_content', comment_author = '$comment_author' WHERE comment_ID = '$comment->comment_ID'");
    333         }
    334     }
    335 
    336     // Remove extraneous backslashes.
     330            $comment_content = addslashes(deslash($comment->comment_content));
     331            $comment_author = addslashes(deslash($comment->comment_author));
     332            $wpdb->query("UPDATE $wpdb->comments SET comment_content = '$comment_content', comment_author = '$comment_author' WHERE comment_ID = '$comment->comment_ID'");
     333        }
     334    }
     335
     336    // Remove extraneous backslashes.
    337337    $links = $wpdb->get_results("SELECT link_id, link_name, link_description FROM $wpdb->links");
    338338    if ($links) {
    339339        foreach($links as $link) {
    340             $link_name = addslashes(deslash($link->link_name));
    341             $link_description = addslashes(deslash($link->link_description));
    342             $wpdb->query("UPDATE $wpdb->links SET link_name = '$link_name', link_description = '$link_description' WHERE link_id = '$link->link_id'");
    343         }
    344     }
    345 
    346     // The "paged" option for what_to_show is no more.
    347     if ($wpdb->get_var("SELECT option_value FROM $wpdb->options WHERE option_name = 'what_to_show'") == 'paged') {
    348         $wpdb->query("UPDATE $wpdb->options SET option_value = 'posts' WHERE option_name = 'what_to_show'");
    349     }
    350 
    351         $active_plugins = __get_option('active_plugins');
    352 
    353         // If plugins are not stored in an array, they're stored in the old
    354         // newline separated format.  Convert to new format.
    355         if ( !is_array( $active_plugins ) ) {
    356             $active_plugins = explode("\n", trim($active_plugins));
    357             update_option('active_plugins', $active_plugins);
    358         }
     340            $link_name = addslashes(deslash($link->link_name));
     341            $link_description = addslashes(deslash($link->link_description));
     342            $wpdb->query("UPDATE $wpdb->links SET link_name = '$link_name', link_description = '$link_description' WHERE link_id = '$link->link_id'");
     343        }
     344    }
     345
     346    // The "paged" option for what_to_show is no more.
     347    if ($wpdb->get_var("SELECT option_value FROM $wpdb->options WHERE option_name = 'what_to_show'") == 'paged') {
     348        $wpdb->query("UPDATE $wpdb->options SET option_value = 'posts' WHERE option_name = 'what_to_show'");
     349    }
     350
     351    $active_plugins = __get_option('active_plugins');
     352
     353    // If plugins are not stored in an array, they're stored in the old
     354    // newline separated format.  Convert to new format.
     355    if ( !is_array( $active_plugins ) ) {
     356        $active_plugins = explode("\n", trim($active_plugins));
     357        update_option('active_plugins', $active_plugins);
     358    }
    359359
    360360    // Obsolete tables
     
    500500        $now = gmdate('Y-m-d H:i:59');
    501501        $wpdb->query ("UPDATE $wpdb->posts SET post_status = 'future' WHERE post_status = 'publish' AND post_date_gmt > '$now'");
    502        
     502
    503503        $posts = $wpdb->get_results("SELECT ID, post_date FROM $wpdb->posts WHERE post_status ='future'");
    504504        if ( !empty($posts) )
     
    509509        // Create categories for link categories if a category with the same
    510510        // name doesn't exist.  Create a map of link cat IDs to cat IDs.
    511         $link_cats = $wpdb->get_results("SELECT cat_id, cat_name FROM $wpdb->linkcategories"); 
     511        $link_cats = $wpdb->get_results("SELECT cat_id, cat_name FROM $wpdb->linkcategories");
    512512        foreach ( $link_cats as $link_cat) {
    513513            if ( $cat_id = category_exists($link_cat->cat_name) ) {
     
    528528                $wpdb->query("INSERT INTO $wpdb->link2cat (link_id, category_id)
    529529                    VALUES ('$link->link_id', '$link_cat')");
    530             }           
    531         }
    532        
     530            }
     531        }
     532
    533533        // Set default to the last category we grabbed during the upgrade loop.
    534534        update_option('default_link_category', $default_link_cat);
     
    549549// General
    550550function maybe_create_table($table_name, $create_ddl) {
    551     global $wpdb;
    552     foreach ($wpdb->get_col("SHOW TABLES",0) as $table ) {
    553         if ($table == $table_name) {
    554             return true;
    555         }
    556     }
    557     //didn't find it try to create it.
    558     $q = $wpdb->query($create_ddl);
    559     // we cannot directly tell that whether this succeeded!
    560     foreach ($wpdb->get_col("SHOW TABLES",0) as $table ) {
    561         if ($table == $table_name) {
    562             return true;
    563         }
    564     }
    565     return false;
     551    global $wpdb;
     552    foreach ($wpdb->get_col("SHOW TABLES",0) as $table ) {
     553        if ($table == $table_name) {
     554            return true;
     555        }
     556    }
     557    //didn't find it try to create it.
     558    $q = $wpdb->query($create_ddl);
     559    // we cannot directly tell that whether this succeeded!
     560    foreach ($wpdb->get_col("SHOW TABLES",0) as $table ) {
     561        if ($table == $table_name) {
     562            return true;
     563        }
     564    }
     565    return false;
    566566}
    567567
     
    592592 */
    593593function maybe_add_column($table_name, $column_name, $create_ddl) {
    594     global $wpdb, $debug;
    595     foreach ($wpdb->get_col("DESC $table_name", 0) as $column ) {
    596         if ($debug) echo("checking $column == $column_name<br />");
    597         if ($column == $column_name) {
    598             return true;
    599         }
    600     }
    601     //didn't find it try to create it.
    602     $q = $wpdb->query($create_ddl);
    603     // we cannot directly tell that whether this succeeded!
    604     foreach ($wpdb->get_col("DESC $table_name", 0) as $column ) {
    605         if ($column == $column_name) {
    606             return true;
    607         }
    608     }
    609     return false;
     594    global $wpdb, $debug;
     595    foreach ($wpdb->get_col("DESC $table_name", 0) as $column ) {
     596        if ($debug) echo("checking $column == $column_name<br />");
     597        if ($column == $column_name) {
     598            return true;
     599        }
     600    }
     601    //didn't find it try to create it.
     602    $q = $wpdb->query($create_ddl);
     603    // we cannot directly tell that whether this succeeded!
     604    foreach ($wpdb->get_col("DESC $table_name", 0) as $column ) {
     605        if ($column == $column_name) {
     606            return true;
     607        }
     608    }
     609    return false;
    610610}
    611611
     
    616616    if ($options = $wpdb->get_results("SELECT option_name, option_value FROM $wpdb->options")) {
    617617        foreach ($options as $option) {
    618             // "When trying to design a foolproof system, 
     618            // "When trying to design a foolproof system,
    619619            //  never underestimate the ingenuity of the fools :)" -- Dougal
    620620            if ('siteurl' == $option->option_name) $option->option_value = preg_replace('|/+$|', '', $option->option_value);
     
    647647
    648648function deslash($content) {
    649     // Note: \\\ inside a regex denotes a single backslash.
    650 
    651     // Replace one or more backslashes followed by a single quote with
    652     // a single quote.
    653     $content = preg_replace("/\\\+'/", "'", $content);
    654 
    655     // Replace one or more backslashes followed by a double quote with
    656     // a double quote.
    657     $content = preg_replace('/\\\+"/', '"', $content);
    658 
    659     // Replace one or more backslashes with one backslash.
    660     $content = preg_replace("/\\\+/", "\\", $content);
    661 
    662     return $content;
     649    // Note: \\\ inside a regex denotes a single backslash.
     650
     651    // Replace one or more backslashes followed by a single quote with
     652    // a single quote.
     653    $content = preg_replace("/\\\+'/", "'", $content);
     654
     655    // Replace one or more backslashes followed by a double quote with
     656    // a double quote.
     657    $content = preg_replace('/\\\+"/', '"', $content);
     658
     659    // Replace one or more backslashes with one backslash.
     660    $content = preg_replace("/\\\+/", "\\", $content);
     661
     662    return $content;
    663663}
    664664
     
    827827                            }
    828828                        }
    829                         // Add the column list to the index create string 
     829                        // Add the column list to the index create string
    830830                        $index_string .= ' ('.$index_columns.')';
    831831
Note: See TracChangeset for help on using the changeset viewer.