Enable utf8mb4 for MySQL extension users. Previously utf8mb4 was limited to MySQLi users only unintentionally.

This change does the following things
 * Allows utf8mb4 for the MySQL extension
 * Re-runs the utf8->utf8mb4 conversion for single sites, this will do nothing for tables already converted
 * Re-runs the utf8->utf8mb4 conversion for global tables in multisite when the environment supports utf8mb4
 * Removes upgrade_420() calling as upgrade_430() will perform those changes now instead

The index shortenings should have still taken place on utf8 sites previously, so there's no need to run those again. 

Props kovshenin, pento, dd32
Fixes #32127 for trunk.

Built from https://develop.svn.wordpress.org/trunk@33055


git-svn-id: http://core.svn.wordpress.org/trunk@33026 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Dion Hulse 2015-07-03 03:26:24 +00:00
parent a4e803fbd4
commit cbacb92dae
3 changed files with 24 additions and 27 deletions

View File

@ -531,15 +531,9 @@ function upgrade_all() {
if ( $wp_current_db_version < 29630 )
upgrade_400();
// Don't harsh my mellow. upgrade_430() must be called before
// upgrade_420() to catch bad comments prior to any auto-expansion of
// MySQL column widths.
if ( $wp_current_db_version < 32814 )
if ( $wp_current_db_version < 33055 )
upgrade_430();
if ( $wp_current_db_version < 31351 )
upgrade_420();
maybe_disable_link_manager();
maybe_disable_automattic_widgets();
@ -1494,21 +1488,7 @@ function upgrade_400() {
* @global int $wp_current_db_version
* @global wpdb $wpdb
*/
function upgrade_420() {
global $wp_current_db_version, $wpdb;
if ( $wp_current_db_version < 31351 && $wpdb->charset === 'utf8mb4' ) {
if ( is_multisite() ) {
$tables = $wpdb->tables( 'blog' );
} else {
$tables = $wpdb->tables( 'all' );
}
foreach ( $tables as $table ) {
maybe_convert_table_to_utf8mb4( $table );
}
}
}
function upgrade_420() {}
/**
* Execute changes made in WordPress 4.3.0.
@ -1528,6 +1508,18 @@ function upgrade_430() {
if ( $wp_current_db_version < 32814 ) {
split_all_shared_terms();
}
if ( $wp_current_db_version < 33055 && 'utf8mb4' === $wpdb->charset ) {
if ( is_multisite() ) {
$tables = $wpdb->tables( 'blog' );
} else {
$tables = $wpdb->tables( 'all' );
}
foreach ( $tables as $table ) {
maybe_convert_table_to_utf8mb4( $table );
}
}
}
/**
@ -1696,7 +1688,7 @@ function upgrade_network() {
}
// 4.3
if ( $wp_current_db_version < 32378 && 'utf8mb4' === $wpdb->charset ) {
if ( $wp_current_db_version < 33055 && 'utf8mb4' === $wpdb->charset ) {
if ( ! ( defined( 'DO_NOT_UPGRADE_GLOBAL_TABLES' ) && DO_NOT_UPGRADE_GLOBAL_TABLES ) ) {
$upgrade = false;
$indexes = $wpdb->get_results( "SHOW INDEXES FROM $wpdb->signups" );
@ -1710,6 +1702,12 @@ function upgrade_network() {
if ( $upgrade ) {
$wpdb->query( "ALTER TABLE $wpdb->signups DROP INDEX domain_path, ADD INDEX domain_path(domain(140),path(51))" );
}
$tables = $wpdb->tables( 'global' );
foreach ( $tables as $table ) {
maybe_convert_table_to_utf8mb4( $table );
}
}
}
}

View File

@ -4,14 +4,14 @@
*
* @global string $wp_version
*/
$wp_version = '4.3-beta1-33054';
$wp_version = '4.3-beta1-33055';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
*
* @global int $wp_db_version
*/
$wp_db_version = 32814;
$wp_db_version = 33055;
/**
* Holds the TinyMCE version

View File

@ -740,8 +740,7 @@ class wpdb {
$this->charset = DB_CHARSET;
}
if ( ( $this->use_mysqli && ! ( $this->dbh instanceof mysqli ) )
|| ( empty( $this->dbh ) || ! ( $this->dbh instanceof mysqli ) ) ) {
if ( ( $this->use_mysqli && ! ( $this->dbh instanceof mysqli ) ) || empty( $this->dbh ) ) {
return;
}