upgrade_230()
Execute changes made in WordPress 2.3.
Description Description
Source Source
File: wp-admin/includes/upgrade.php
926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 | if ( '' == $user ->user_nicename ) { $newname = sanitize_title( $user ->user_nickname ); $wpdb ->update( $wpdb ->users, array ( 'user_nicename' => $newname ), array ( 'ID' => $user ->ID ) ); } } $users = $wpdb ->get_results( "SELECT ID, user_pass from $wpdb->users" ); foreach ( $users as $row ) { if ( ! preg_match( '/^[A-Fa-f0-9]{32}$/' , $row ->user_pass ) ) { $wpdb ->update( $wpdb ->users, array ( 'user_pass' => md5( $row ->user_pass ) ), array ( 'ID' => $row ->ID ) ); } } // Get the GMT offset, we'll use that later on $all_options = get_alloptions_110(); $time_difference = $all_options ->time_difference; $server_time = time() + date ( 'Z' ); $weblogger_time = $server_time + $time_difference * HOUR_IN_SECONDS; $gmt_time = time(); $diff_gmt_server = ( $gmt_time - $server_time ) / HOUR_IN_SECONDS; $diff_weblogger_server = ( $weblogger_time - $server_time ) / HOUR_IN_SECONDS; $diff_gmt_weblogger = $diff_gmt_server - $diff_weblogger_server ; $gmt_offset = - $diff_gmt_weblogger ; // Add a gmt_offset option, with value $gmt_offset add_option( 'gmt_offset' , $gmt_offset ); // Check if we already set the GMT fields (if we did, then // MAX(post_date_gmt) can't be '0000-00-00 00:00:00' // <michel_v> I just slapped myself silly for not thinking about it earlier $got_gmt_fields = ! ( $wpdb ->get_var( "SELECT MAX(post_date_gmt) FROM $wpdb->posts" ) == '0000-00-00 00:00:00' ); if ( ! $got_gmt_fields ) { // Add or subtract time to all dates, to get GMT dates $add_hours = intval ( $diff_gmt_weblogger ); $add_minutes = intval ( 60 * ( $diff_gmt_weblogger - $add_hours ) ); $wpdb ->query( "UPDATE $wpdb->posts SET post_date_gmt = DATE_ADD(post_date, INTERVAL '$add_hours:$add_minutes' HOUR_MINUTE)" ); $wpdb ->query( "UPDATE $wpdb->posts SET post_modified = post_date" ); $wpdb ->query( "UPDATE $wpdb->posts SET post_modified_gmt = DATE_ADD(post_modified, INTERVAL '$add_hours:$add_minutes' HOUR_MINUTE) WHERE post_modified != '0000-00-00 00:00:00'" ); $wpdb ->query( "UPDATE $wpdb->comments SET comment_date_gmt = DATE_ADD(comment_date, INTERVAL '$add_hours:$add_minutes' HOUR_MINUTE)" ); $wpdb ->query( "UPDATE $wpdb->users SET user_registered = DATE_ADD(user_registered, INTERVAL '$add_hours:$add_minutes' HOUR_MINUTE)" ); } } /** * Execute changes made in WordPress 1.5. * * @ignore * @since 1.5.0 * * @global wpdb $wpdb WordPress database abstraction object. */ function upgrade_130() { global $wpdb ; // Remove extraneous backslashes. $posts = $wpdb ->get_results( "SELECT ID, post_title, post_content, post_excerpt, guid, post_date, post_name, post_status, post_author FROM $wpdb->posts" ); if ( $posts ) { foreach ( $posts as $post ) { $post_content = addslashes ( deslash( $post ->post_content ) ); $post_title = addslashes ( deslash( $post ->post_title ) ); $post_excerpt = addslashes ( deslash( $post ->post_excerpt ) ); if ( empty ( $post ->guid ) ) { $guid = get_permalink( $post ->ID ); } else { $guid = $post ->guid; } $wpdb ->update( $wpdb ->posts, compact( 'post_title' , 'post_content' , 'post_excerpt' , 'guid' ), array ( 'ID' => $post ->ID ) ); } } // Remove extraneous backslashes. $comments = $wpdb ->get_results( "SELECT comment_ID, comment_author, comment_content FROM $wpdb->comments" ); if ( $comments ) { foreach ( $comments as $comment ) { $comment_content = deslash( $comment ->comment_content ); $comment_author = deslash( $comment ->comment_author ); $wpdb ->update( $wpdb ->comments, compact( 'comment_content' , 'comment_author' ), array ( 'comment_ID' => $comment ->comment_ID ) ); } } // Remove extraneous backslashes. $links = $wpdb ->get_results( "SELECT link_id, link_name, link_description FROM $wpdb->links" ); if ( $links ) { foreach ( $links as $link ) { $link_name = deslash( $link ->link_name ); $link_description = deslash( $link ->link_description ); $wpdb ->update( $wpdb ->links, compact( 'link_name' , 'link_description' ), array ( 'link_id' => $link ->link_id ) ); } } $active_plugins = __get_option( 'active_plugins' ); /* * If plugins are not stored in an array, they're stored in the old * newline separated format. Convert to new format. */ if ( ! is_array ( $active_plugins ) ) { $active_plugins = explode ( "\n" , trim( $active_plugins ) ); update_option( 'active_plugins' , $active_plugins ); } // Obsolete tables $wpdb ->query( 'DROP TABLE IF EXISTS ' . $wpdb ->prefix . 'optionvalues' ); $wpdb ->query( 'DROP TABLE IF EXISTS ' . $wpdb ->prefix . 'optiontypes' ); $wpdb ->query( 'DROP TABLE IF EXISTS ' . $wpdb ->prefix . 'optiongroups' ); $wpdb ->query( 'DROP TABLE IF EXISTS ' . $wpdb ->prefix . 'optiongroup_options' ); // Update comments table to use comment_type $wpdb ->query( "UPDATE $wpdb->comments SET comment_type='trackback', comment_content = REPLACE(comment_content, '<trackback />', '') WHERE comment_content LIKE '<trackback />%'" ); $wpdb ->query( "UPDATE $wpdb->comments SET comment_type='pingback', comment_content = REPLACE(comment_content, '<pingback />', '') WHERE comment_content LIKE '<pingback />%'" ); // Some versions have multiple duplicate option_name rows with the same values $options = $wpdb ->get_results( "SELECT option_name, COUNT(option_name) AS dupes FROM `$wpdb->options` GROUP BY option_name" ); foreach ( $options as $option ) { if ( 1 != $option ->dupes ) { // Could this be done in the query? $limit = $option ->dupes - 1; $dupe_ids = $wpdb ->get_col( $wpdb ->prepare( "SELECT option_id FROM $wpdb->options WHERE option_name = %s LIMIT %d" , $option ->option_name, $limit ) ); if ( $dupe_ids ) { $dupe_ids = join( $dupe_ids , ',' ); $wpdb ->query( "DELETE FROM $wpdb->options WHERE option_id IN ($dupe_ids)" ); } } } make_site_theme(); } /** * Execute changes made in WordPress 2.0. * * @ignore * @since 2.0.0 * * @global wpdb $wpdb WordPress database abstraction object. * @global int $wp_current_db_version */ function upgrade_160() { global $wpdb , $wp_current_db_version ; populate_roles_160(); $users = $wpdb ->get_results( "SELECT * FROM $wpdb->users" ); foreach ( $users as $user ) : if ( ! empty ( $user ->user_firstname ) ) { update_user_meta( $user ->ID, 'first_name' , wp_slash( $user ->user_firstname ) ); } if ( ! empty ( $user ->user_lastname ) ) { update_user_meta( $user ->ID, 'last_name' , wp_slash( $user ->user_lastname ) ); } if ( ! empty ( $user ->user_nickname ) ) { update_user_meta( $user ->ID, 'nickname' , wp_slash( $user ->user_nickname ) ); } if ( ! empty ( $user ->user_level ) ) { update_user_meta( $user ->ID, $wpdb ->prefix . 'user_level' , $user ->user_level ); } if ( ! empty ( $user ->user_icq ) ) { update_user_meta( $user ->ID, 'icq' , wp_slash( $user ->user_icq ) ); } if ( ! empty ( $user ->user_aim ) ) { update_user_meta( $user ->ID, 'aim' , wp_slash( $user ->user_aim ) ); |
Expand full source code Collapse full source code View on Trac
Changelog Changelog
Version | Description |
---|---|
2.3.0 | Introduced. |