From cbacb92daee7a9fb042173390823bbd2e60bc5eb Mon Sep 17 00:00:00 2001 From: Dion Hulse Date: Fri, 3 Jul 2015 03:26:24 +0000 Subject: [PATCH] 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 --- wp-admin/includes/upgrade.php | 44 +++++++++++++++++------------------ wp-includes/version.php | 4 ++-- wp-includes/wp-db.php | 3 +-- 3 files changed, 24 insertions(+), 27 deletions(-) diff --git a/wp-admin/includes/upgrade.php b/wp-admin/includes/upgrade.php index 03d8fd0d52..fa1cf4984a 100644 --- a/wp-admin/includes/upgrade.php +++ b/wp-admin/includes/upgrade.php @@ -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 ); + } } } } diff --git a/wp-includes/version.php b/wp-includes/version.php index 51763a69a9..88475f1df8 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -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 diff --git a/wp-includes/wp-db.php b/wp-includes/wp-db.php index 42792a4d78..2f6d4f484c 100644 --- a/wp-includes/wp-db.php +++ b/wp-includes/wp-db.php @@ -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; }