From 6a9d744b42728769d3b3758e93a4f1fe859977d2 Mon Sep 17 00:00:00 2001 From: Gary Pendergast Date: Wed, 1 Apr 2015 02:22:31 +0000 Subject: [PATCH] WPDB: When we check the character set of a column, and find that it's `utf8mb4`, we should also check that the current connection supports `utf8mb4`. It's possible that the environment may have changed since upgrading the DB, so we can fall back to `utf8` when that happens. Fixes #31771. Built from https://develop.svn.wordpress.org/trunk@31947 git-svn-id: http://core.svn.wordpress.org/trunk@31926 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/version.php | 2 +- wp-includes/wp-db.php | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/wp-includes/version.php b/wp-includes/version.php index e8463c8c9f..82281d4a19 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.2-beta3-31946'; +$wp_version = '4.2-beta3-31947'; /** * 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 91ad6f2286..ac9f24e6cd 100644 --- a/wp-includes/wp-db.php +++ b/wp-includes/wp-db.php @@ -2219,6 +2219,12 @@ class wpdb { foreach ( $columns as $column ) { if ( ! empty( $column->Collation ) ) { list( $charset ) = explode( '_', $column->Collation ); + + // If the current connection can't support utf8mb4 characters, let's only send 3-byte utf8 characters. + if ( 'utf8mb4' === $charset && ! $this->has_cap( 'utf8mb4' ) ) { + $charset = 'utf8'; + } + $charsets[ strtolower( $charset ) ] = true; }