*
* @since 2.1.0
*
- * @param string $blog_title Blog title.
+ * @param string $blog_title Site title.
* @param string $user_name User's username.
* @param string $user_email User's email.
- * @param bool $public Whether blog is public.
+ * @param bool $public Whether site is public.
* @param string $deprecated Optional. Not used.
* @param string $user_password Optional. User's chosen password. Default empty (random password).
* @param string $language Optional. Language chosen. Default empty.
/*
* Create default user. If the user already exists, the user tables are
- * being shared among blogs. Just set the role in that case.
+ * being shared among sites. Just set the role in that case.
*/
$user_id = username_exists($user_name);
$user_password = trim($user_password);
if ( is_multisite() ) {
$first_post = get_site_option( 'first_post' );
- if ( empty($first_post) )
- $first_post = __( 'Welcome to <a href="SITE_URL">SITE_NAME</a>. 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( '<a href="%s">%s</a>', 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!' );
}
*
* @since 2.1.0
*
- * @param string $blog_title Blog title.
- * @param string $blog_url Blog url.
+ * @param string $blog_title Site title.
+ * @param string $blog_url Site url.
* @param int $user_id User ID.
* @param string $password User's Password.
*/
*
* @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;
* Contains conditional checks to determine which upgrade scripts to run,
* based on database version and WP version being updated-to.
*
+ * @ignore
* @since 1.0.1
*
* @global int $wp_current_db_version
if ( $wp_current_db_version < 33056 )
upgrade_431();
+ if ( $wp_current_db_version < 35700 )
+ upgrade_440();
+
+ if ( $wp_current_db_version < 36686 )
+ upgrade_450();
+
maybe_disable_link_manager();
maybe_disable_automattic_widgets();
/**
* Execute changes made in WordPress 1.0.
*
+ * @ignore
* @since 1.0.0
*
- * @global wpdb $wpdb
+ * @global wpdb $wpdb WordPress database abstraction object.
*/
function upgrade_100() {
global $wpdb;
// 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) );
/**
* Execute changes made in WordPress 1.0.1.
*
+ * @ignore
* @since 1.0.1
*
- * @global wpdb $wpdb
+ * @global wpdb $wpdb WordPress database abstraction object.
*/
function upgrade_101() {
global $wpdb;
/**
* Execute changes made in WordPress 1.2.
*
+ * @ignore
* @since 1.2.0
*
- * @global wpdb $wpdb
+ * @global wpdb $wpdb WordPress database abstraction object.
*/
function upgrade_110() {
global $wpdb;
/**
* Execute changes made in WordPress 1.5.
*
+ * @ignore
* @since 1.5.0
*
- * @global wpdb $wpdb
+ * @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) {
+ 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));
// 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);
// 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);
/**
* Execute changes made in WordPress 2.0.
*
+ * @ignore
* @since 2.0.0
*
- * @global wpdb $wpdb
+ * @global wpdb $wpdb WordPress database abstraction object.
* @global int $wp_current_db_version
*/
function upgrade_160() {
/**
* Execute changes made in WordPress 2.1.
*
+ * @ignore
* @since 2.1.0
*
- * @global wpdb $wpdb
+ * @global wpdb $wpdb WordPress database abstraction object.
* @global int $wp_current_db_version
*/
function upgrade_210() {
/**
* Execute changes made in WordPress 2.3.
*
+ * @ignore
* @since 2.3.0
*
- * @global wpdb $wpdb
+ * @global wpdb $wpdb WordPress database abstraction object.
* @global int $wp_current_db_version
*/
function upgrade_230() {
/**
* Remove old options from the database.
*
+ * @ignore
* @since 2.3.0
*
- * @global wpdb $wpdb
+ * @global wpdb $wpdb WordPress database abstraction object.
*/
function upgrade_230_options_table() {
global $wpdb;
/**
* Remove old categories, link2cat, and post2cat database tables.
*
+ * @ignore
* @since 2.3.0
*
- * @global wpdb $wpdb
+ * @global wpdb $wpdb WordPress database abstraction object.
*/
function upgrade_230_old_tables() {
global $wpdb;
/**
* Upgrade old slugs made in version 2.2.
*
+ * @ignore
* @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.
/**
* Execute changes made in WordPress 2.5.0.
*
+ * @ignore
* @since 2.5.0
*
* @global int $wp_current_db_version
/**
* Execute changes made in WordPress 2.5.2.
*
+ * @ignore
* @since 2.5.2
*
- * @global wpdb $wpdb
+ * @global wpdb $wpdb WordPress database abstraction object.
*/
function upgrade_252() {
global $wpdb;
/**
* Execute changes made in WordPress 2.6.
*
+ * @ignore
* @since 2.6.0
*
* @global int $wp_current_db_version
/**
* Execute changes made in WordPress 2.7.
*
+ * @ignore
* @since 2.7.0
*
- * @global wpdb $wpdb
+ * @global wpdb $wpdb WordPress database abstraction object.
* @global int $wp_current_db_version
*/
function upgrade_270() {
/**
* Execute changes made in WordPress 2.8.
*
+ * @ignore
* @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;
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 );
/**
* Execute changes made in WordPress 2.9.
*
+ * @ignore
* @since 2.9.0
*
* @global int $wp_current_db_version
/**
* Execute changes made in WordPress 3.0.
*
+ * @ignore
* @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;
/**
* Execute changes made in WordPress 3.3.
*
+ * @ignore
* @since 3.3.0
*
* @global int $wp_current_db_version
/**
* Execute changes made in WordPress 3.4.
*
+ * @ignore
* @since 3.4.0
*
* @global int $wp_current_db_version
/**
* Execute changes made in WordPress 3.5.
*
+ * @ignore
* @since 3.5.0
*
* @global int $wp_current_db_version
/**
* Execute changes made in WordPress 3.7.
*
+ * @ignore
* @since 3.7.0
*
* @global int $wp_current_db_version
/**
* Execute changes made in WordPress 3.7.2.
*
+ * @ignore
* @since 3.7.2
* @since 3.8.0
*
/**
* Execute changes made in WordPress 3.8.0.
*
+ * @ignore
* @since 3.8.0
*
* @global int $wp_current_db_version
/**
* Execute changes made in WordPress 4.0.0.
*
+ * @ignore
* @since 4.0.0
*
* @global int $wp_current_db_version
/**
* Execute changes made in WordPress 4.2.0.
*
+ * @ignore
* @since 4.2.0
*
* @global int $wp_current_db_version
/**
* Executes changes made in WordPress 4.3.0.
*
+ * @ignore
* @since 4.3.0
*
* @global int $wp_current_db_version Current version.
/**
* Executes comments changes made in WordPress 4.3.0.
*
+ * @ignore
* @since 4.3.0
*
* @global int $wp_current_db_version Current version.
/**
* Executes changes made in WordPress 4.3.1.
*
+ * @ignore
* @since 4.3.1
*/
function upgrade_431() {
}
}
+/**
+ * Executes changes made in WordPress 4.4.0.
+ *
+ * @ignore
+ * @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 changes made in WordPress 4.5.0.
+ *
+ * @ignore
+ * @since 4.5.0
+ *
+ * @global int $wp_current_db_version Current database version.
+ * @global wpdb $wpdb WordPress database abstraction object.
+ */
+function upgrade_450() {
+ global $wp_current_db_version, $wpdb;
+
+ if ( $wp_current_db_version < 36180 ) {
+ wp_clear_scheduled_hook( 'wp_maybe_auto_update' );
+ }
+
+ // Remove unused email confirmation options, moved to usermeta.
+ if ( $wp_current_db_version < 36679 && is_multisite() ) {
+ $wpdb->query( "DELETE FROM $wpdb->options WHERE option_name REGEXP '^[0-9]+_new_email$'" );
+ }
+
+ // Remove unused user setting for wpLink.
+ delete_user_setting( 'wplink' );
+}
+
/**
* Executes network-level upgrade routines.
*
$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 );
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;
$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];
*/
$iqueries = apply_filters( 'dbdelta_insert_queries', $iqueries );
+ $text_fields = array( 'tinytext', 'text', 'mediumtext', 'longtext' );
+ $blob_fields = array( 'tinyblob', 'blob', 'mediumblob', 'longblob' );
+
$global_tables = $wpdb->tables( 'global' );
foreach ( $cqueries as $table => $qry ) {
// Upgrade global tables only for the main site. Don't upgrade at all if conditions are not optimal.
// Is actual field type different from the field type in query?
if ($tablefield->Type != $fieldtype) {
+ $do_change = true;
+ if ( in_array( strtolower( $fieldtype ), $text_fields ) && in_array( strtolower( $tablefield->Type ), $text_fields ) ) {
+ if ( array_search( strtolower( $fieldtype ), $text_fields ) < array_search( strtolower( $tablefield->Type ), $text_fields ) ) {
+ $do_change = false;
+ }
+ }
+
+ if ( in_array( strtolower( $fieldtype ), $blob_fields ) && in_array( strtolower( $tablefield->Type ), $blob_fields ) ) {
+ if ( array_search( strtolower( $fieldtype ), $blob_fields ) < array_search( strtolower( $tablefield->Type ), $blob_fields ) ) {
+ $do_change = false;
+ }
+ }
+
+ if ( $do_change ) {
// Add a query to change the column type
- $cqueries[] = "ALTER TABLE {$table} CHANGE COLUMN {$tablefield->Field} " . $cfields[strtolower($tablefield->Field)];
- $for_update[$table.'.'.$tablefield->Field] = "Changed type of {$table}.{$tablefield->Field} from {$tablefield->Type} to {$fieldtype}";
+ $cqueries[] = "ALTER TABLE {$table} CHANGE COLUMN {$tablefield->Field} " . $cfields[strtolower($tablefield->Field)];
+ $for_update[$table.'.'.$tablefield->Field] = "Changed type of {$table}.{$tablefield->Field} from {$tablefield->Type} to {$fieldtype}";
+ }
}
// Get the default value from the array
$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.
} 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;
"$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;
function make_db_current( $tables = 'all' ) {
$alterations = dbDelta( $tables );
echo "<ol>\n";
- foreach($alterations as $alteration) echo "<li>$alteration</li>\n";
+ foreach ($alterations as $alteration) echo "<li>$alteration</li>\n";
echo "</ol>\n";
}
* @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;
* @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;
$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 );
+ }
+ }
}
/**