From 1aff99307f76b9c971f1eaa755a4b1d91b134d0d Mon Sep 17 00:00:00 2001 From: Gary Pendergast Date: Mon, 23 May 2016 05:54:27 +0000 Subject: [PATCH] Database: Obey locale-specific `utf8` collation settings. Some sites prefer to use locale-specific location settings. For example, the Swedish WordPress package use `utf8_swedish_ci`, instead of `utf8_unicode_ci`. When upgrading the connection to `utf8mb4`, we were overriding this to be `utf8mb4_unicode_ci`, instead of maintaining the use of the `_swedish_ci` variant. The locale-specific collations do have extra collation rules just for that language, so it's useful to maintain compatibility. Fixes #32405. Built from https://develop.svn.wordpress.org/trunk@37521 git-svn-id: http://core.svn.wordpress.org/trunk@37489 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/version.php | 2 +- wp-includes/wp-db.php | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/wp-includes/version.php b/wp-includes/version.php index d9c2294428..29d58cfce3 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.6-alpha-37520'; +$wp_version = '4.6-alpha-37521'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. diff --git a/wp-includes/wp-db.php b/wp-includes/wp-db.php index 6fcc31a7eb..8d9f84c63e 100644 --- a/wp-includes/wp-db.php +++ b/wp-includes/wp-db.php @@ -757,8 +757,13 @@ class wpdb { $this->charset = 'utf8mb4'; } - if ( 'utf8mb4' === $this->charset && ( ! $this->collate || stripos( $this->collate, 'utf8_' ) === 0 ) ) { - $this->collate = 'utf8mb4_unicode_ci'; + if ( 'utf8mb4' === $this->charset ) { + // _general_ is outdated, so we can upgrade it to _unicode_, instead. + if ( ! $this->collate || 'utf8_general_ci' === $this->collate ) { + $this->collate = 'utf8mb4_unicode_ci'; + } else { + $this->collate = str_replace( 'utf8_', 'utf8mb4_', $this->collate ); + } } }