X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/f34e3c5e1f96e4214461c0b72b651ad48ccffe50..3194d1bb103c2d8db4f44feeced5e58ee2756658:/wp-admin/includes/upgrade.php diff --git a/wp-admin/includes/upgrade.php b/wp-admin/includes/upgrade.php index 95381faa..72d99b77 100644 --- a/wp-admin/includes/upgrade.php +++ b/wp-admin/includes/upgrade.php @@ -155,11 +155,18 @@ function wp_install_defaults( $user_id ) { if ( is_multisite() ) { $first_post = get_site_option( 'first_post' ); - if ( empty($first_post) ) - $first_post = __( 'Welcome to SITE_NAME. This is your first post. Edit or delete it, then start writing!' ); + if ( ! $first_post ) { + /* translators: %s: site link */ + $first_post = __( 'Welcome to %s. This is your first post. Edit or delete it, then start blogging!' ); + } + + $first_post = sprintf( $first_post, + sprintf( '%s', esc_url( network_home_url() ), get_current_site()->site_name ) + ); - $first_post = str_replace( "SITE_URL", esc_url( network_home_url() ), $first_post ); - $first_post = str_replace( "SITE_NAME", get_current_site()->site_name, $first_post ); + // Back-compat for pre-4.4 + $first_post = str_replace( 'SITE_URL', esc_url( network_home_url() ), $first_post ); + $first_post = str_replace( 'SITE_NAME', get_current_site()->site_name, $first_post ); } else { $first_post = __( 'Welcome to WordPress. This is your first post. Edit or delete it, then start writing!' ); } @@ -392,7 +399,7 @@ if ( !function_exists('wp_upgrade') ) : * * @global int $wp_current_db_version * @global int $wp_db_version - * @global wpdb $wpdb + * @global wpdb $wpdb WordPress database abstraction object. */ function wp_upgrade() { global $wp_current_db_version, $wp_db_version, $wpdb; @@ -538,6 +545,9 @@ function upgrade_all() { if ( $wp_current_db_version < 33056 ) upgrade_431(); + if ( $wp_current_db_version < 35700 ) + upgrade_440(); + maybe_disable_link_manager(); maybe_disable_automattic_widgets(); @@ -551,7 +561,7 @@ function upgrade_all() { * * @since 1.0.0 * - * @global wpdb $wpdb + * @global wpdb $wpdb WordPress database abstraction object. */ function upgrade_100() { global $wpdb; @@ -559,7 +569,7 @@ function upgrade_100() { // Get the title and ID of every post, post_name to check if it already has a value $posts = $wpdb->get_results("SELECT ID, post_title, post_name FROM $wpdb->posts WHERE post_name = ''"); if ($posts) { - foreach($posts as $post) { + foreach ($posts as $post) { if ('' == $post->post_name) { $newtitle = sanitize_title($post->post_title); $wpdb->query( $wpdb->prepare("UPDATE $wpdb->posts SET post_name = %s WHERE ID = %d", $newtitle, $post->ID) ); @@ -609,7 +619,7 @@ function upgrade_100() { * * @since 1.0.1 * - * @global wpdb $wpdb + * @global wpdb $wpdb WordPress database abstraction object. */ function upgrade_101() { global $wpdb; @@ -629,7 +639,7 @@ function upgrade_101() { * * @since 1.2.0 * - * @global wpdb $wpdb + * @global wpdb $wpdb WordPress database abstraction object. */ function upgrade_110() { global $wpdb; @@ -691,7 +701,7 @@ function upgrade_110() { * * @since 1.5.0 * - * @global wpdb $wpdb + * @global wpdb $wpdb WordPress database abstraction object. */ function upgrade_130() { global $wpdb; @@ -699,7 +709,7 @@ function upgrade_130() { // 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) { + 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)); @@ -716,7 +726,7 @@ function upgrade_130() { // Remove extraneous backslashes. $comments = $wpdb->get_results("SELECT comment_ID, comment_author, comment_content FROM $wpdb->comments"); if ($comments) { - foreach($comments as $comment) { + foreach ($comments as $comment) { $comment_content = deslash($comment->comment_content); $comment_author = deslash($comment->comment_author); @@ -727,7 +737,7 @@ function upgrade_130() { // Remove extraneous backslashes. $links = $wpdb->get_results("SELECT link_id, link_name, link_description FROM $wpdb->links"); if ($links) { - foreach($links as $link) { + foreach ($links as $link) { $link_name = deslash($link->link_name); $link_description = deslash($link->link_description); @@ -777,7 +787,7 @@ function upgrade_130() { * * @since 2.0.0 * - * @global wpdb $wpdb + * @global wpdb $wpdb WordPress database abstraction object. * @global int $wp_current_db_version */ function upgrade_160() { @@ -863,7 +873,7 @@ function upgrade_160() { * * @since 2.1.0 * - * @global wpdb $wpdb + * @global wpdb $wpdb WordPress database abstraction object. * @global int $wp_current_db_version */ function upgrade_210() { @@ -910,7 +920,7 @@ function upgrade_210() { * * @since 2.3.0 * - * @global wpdb $wpdb + * @global wpdb $wpdb WordPress database abstraction object. * @global int $wp_current_db_version */ function upgrade_230() { @@ -1089,7 +1099,7 @@ function upgrade_230() { * * @since 2.3.0 * - * @global wpdb $wpdb + * @global wpdb $wpdb WordPress database abstraction object. */ function upgrade_230_options_table() { global $wpdb; @@ -1105,7 +1115,7 @@ function upgrade_230_options_table() { * * @since 2.3.0 * - * @global wpdb $wpdb + * @global wpdb $wpdb WordPress database abstraction object. */ function upgrade_230_old_tables() { global $wpdb; @@ -1119,7 +1129,7 @@ function upgrade_230_old_tables() { * * @since 2.2.0 * - * @global wpdb $wpdb + * @global wpdb $wpdb WordPress database abstraction object. */ function upgrade_old_slugs() { // Upgrade people who were using the Redirect Old Slugs plugin. @@ -1148,7 +1158,7 @@ function upgrade_250() { * * @since 2.5.2 * - * @global wpdb $wpdb + * @global wpdb $wpdb WordPress database abstraction object. */ function upgrade_252() { global $wpdb; @@ -1175,7 +1185,7 @@ function upgrade_260() { * * @since 2.7.0 * - * @global wpdb $wpdb + * @global wpdb $wpdb WordPress database abstraction object. * @global int $wp_current_db_version */ function upgrade_270() { @@ -1195,7 +1205,7 @@ function upgrade_270() { * @since 2.8.0 * * @global int $wp_current_db_version - * @global wpdb $wpdb + * @global wpdb $wpdb WordPress database abstraction object. */ function upgrade_280() { global $wp_current_db_version, $wpdb; @@ -1205,7 +1215,7 @@ function upgrade_280() { if ( is_multisite() ) { $start = 0; while( $rows = $wpdb->get_results( "SELECT option_name, option_value FROM $wpdb->options ORDER BY option_id LIMIT $start, 20" ) ) { - foreach( $rows as $row ) { + foreach ( $rows as $row ) { $value = $row->option_value; if ( !@unserialize( $value ) ) $value = stripslashes( $value ); @@ -1244,7 +1254,7 @@ function upgrade_290() { * @since 3.0.0 * * @global int $wp_current_db_version - * @global wpdb $wpdb + * @global wpdb $wpdb WordPress database abstraction object. */ function upgrade_300() { global $wp_current_db_version, $wpdb; @@ -1595,6 +1605,30 @@ function upgrade_431() { } } +/** + * Executes changes made in WordPress 4.4.0. + * + * @since 4.4.0 + * + * @global int $wp_current_db_version Current version. + * @global wpdb $wpdb WordPress database abstraction object. + */ +function upgrade_440() { + global $wp_current_db_version, $wpdb; + + if ( $wp_current_db_version < 34030 ) { + $wpdb->query( "ALTER TABLE {$wpdb->options} MODIFY option_name VARCHAR(191)" ); + } + + // Remove the unused 'add_users' role. + $roles = wp_roles(); + foreach ( $roles->role_objects as $role ) { + if ( $role->has_cap( 'add_users' ) ) { + $role->remove_cap( 'add_users' ); + } + } +} + /** * Executes network-level upgrade routines. * @@ -1639,7 +1673,7 @@ function upgrade_network() { $start = 0; while( $rows = $wpdb->get_results( "SELECT meta_key, meta_value FROM {$wpdb->sitemeta} ORDER BY meta_id LIMIT $start, 20" ) ) { - foreach( $rows as $row ) { + foreach ( $rows as $row ) { $value = $row->meta_value; if ( !@unserialize( $value ) ) $value = stripslashes( $value ); @@ -1721,7 +1755,7 @@ function upgrade_network() { if ( wp_should_upgrade_global_tables() ) { $upgrade = false; $indexes = $wpdb->get_results( "SHOW INDEXES FROM $wpdb->signups" ); - foreach( $indexes as $index ) { + foreach ( $indexes as $index ) { if ( 'domain_path' == $index->Key_name && 'domain' == $index->Column_name && 140 != $index->Sub_part ) { $upgrade = true; break; @@ -2025,7 +2059,7 @@ function dbDelta( $queries = '', $execute = true ) { $for_update = array(); // Create a tablename index for an array ($cqueries) of queries - foreach($queries as $qry) { + foreach ($queries as $qry) { if ( preg_match( "|CREATE TABLE ([^ ]*)|", $qry, $matches ) ) { $cqueries[ trim( $matches[1], '`' ) ] = $qry; $for_update[$matches[1]] = 'Created table '.$matches[1]; @@ -2176,6 +2210,7 @@ function dbDelta( $queries = '', $execute = true ) { $keyname = $tableindex->Key_name; $index_ary[$keyname]['columns'][] = array('fieldname' => $tableindex->Column_name, 'subpart' => $tableindex->Sub_part); $index_ary[$keyname]['unique'] = ($tableindex->Non_unique == 0)?true:false; + $index_ary[$keyname]['index_type'] = $tableindex->Index_type; } // For each actual index in the index array. @@ -2188,6 +2223,9 @@ function dbDelta( $queries = '', $execute = true ) { } elseif ( $index_data['unique'] ) { $index_string .= 'UNIQUE '; } + if ( 'FULLTEXT' === strtoupper( $index_data['index_type'] ) ) { + $index_string .= 'FULLTEXT '; + } $index_string .= 'KEY '; if ($index_name != 'PRIMARY') { $index_string .= $index_name; @@ -2214,7 +2252,7 @@ function dbDelta( $queries = '', $execute = true ) { "$index_string ($alt_index_columns)", ); - foreach( $index_strings as $index_string ) { + foreach ( $index_strings as $index_string ) { if ( ! ( ( $aindex = array_search( $index_string, $indices ) ) === false ) ) { unset( $indices[ $aindex ] ); break; @@ -2265,7 +2303,7 @@ function dbDelta( $queries = '', $execute = true ) { function make_db_current( $tables = 'all' ) { $alterations = dbDelta( $tables ); echo "
    \n"; - foreach($alterations as $alteration) echo "
  1. $alteration
  2. \n"; + foreach ($alterations as $alteration) echo "
  3. $alteration
  4. \n"; echo "
\n"; } @@ -2549,7 +2587,7 @@ function maybe_disable_automattic_widgets() { * @since 3.5.0 * * @global int $wp_current_db_version - * @global wpdb $wpdb + * @global wpdb $wpdb WordPress database abstraction object. */ function maybe_disable_link_manager() { global $wp_current_db_version, $wpdb; @@ -2564,7 +2602,7 @@ function maybe_disable_link_manager() { * @since 2.9.0 * * @global int $wp_current_db_version - * @global wpdb $wpdb + * @global wpdb $wpdb WordPress database abstraction object. */ function pre_schema_upgrade() { global $wp_current_db_version, $wpdb; @@ -2609,6 +2647,15 @@ function pre_schema_upgrade() { $wpdb->query( "ALTER TABLE $wpdb->postmeta DROP INDEX meta_key, ADD INDEX meta_key(meta_key(191))" ); $wpdb->query( "ALTER TABLE $wpdb->posts DROP INDEX post_name, ADD INDEX post_name(post_name(191))" ); } + + // Upgrade versions prior to 4.4. + if ( $wp_current_db_version < 34978 ) { + // If compatible termmeta table is found, use it, but enforce a proper index and update collation. + if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->termmeta}'" ) && $wpdb->get_results( "SHOW INDEX FROM {$wpdb->termmeta} WHERE Column_name = 'meta_key'" ) ) { + $wpdb->query( "ALTER TABLE $wpdb->termmeta DROP INDEX meta_key, ADD INDEX meta_key(meta_key(191))" ); + maybe_convert_table_to_utf8mb4( $wpdb->termmeta ); + } + } } /**