From cc8a9824c51c208adfee59a91272629ea39e367d Mon Sep 17 00:00:00 2001 From: Gary Pendergast Date: Wed, 22 Apr 2015 15:01:25 +0000 Subject: [PATCH] WPDB: When sanity checking a string by sending it to MySQL for conversion checks, the incorrect data structure was being returned from `wpdb::strip_invalid_text()`, causing all write queries to fail for some character sets when the query contained non-ASCII characters. See #32051. git-svn-id: https://develop.svn.wordpress.org/trunk@32261 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/wp-db.php | 1 + tests/phpunit/tests/db/charset.php | 14 ++++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/wp-includes/wp-db.php b/src/wp-includes/wp-db.php index 489b80d3fb..5e5cd1eefd 100644 --- a/src/wp-includes/wp-db.php +++ b/src/wp-includes/wp-db.php @@ -2542,6 +2542,7 @@ class wpdb { // Split the CONVERT() calls by charset, so we can make sure the connection is right $queries[ $value['charset'] ][ $col ] = $this->prepare( "CONVERT( %s USING {$value['charset']} )", $value['value'] ); + unset( $data[ $col ]['db'] ); } } diff --git a/tests/phpunit/tests/db/charset.php b/tests/phpunit/tests/db/charset.php index 3e0b81ad8a..4ae81d8ba8 100755 --- a/tests/phpunit/tests/db/charset.php +++ b/tests/phpunit/tests/db/charset.php @@ -55,18 +55,24 @@ class Tests_DB_Charset extends WP_UnitTestCase { 'expected' => "H€llo\xf0\x9f\x98\x88World¢" ), 'koi8r' => array( - // koi8r is a character set that needs to be checked in MySQL 'charset' => 'koi8r', 'value' => "\xfdord\xf2ress", 'expected' => "\xfdord\xf2ress", - 'db' => true ), 'hebrew' => array( - // hebrew needs to be checked in MySQL, too 'charset' => 'hebrew', 'value' => "\xf9ord\xf7ress", 'expected' => "\xf9ord\xf7ress", - 'db' => true + ), + 'cp1251' => array( + 'charset' => 'cp1251', + 'value' => "\xd8ord\xd0ress", + 'expected' => "\xd8ord\xd0ress", + ), + 'tis620' => array( + 'charset' => 'tis620', + 'value' => "\xccord\xe3ress", + 'expected' => "\xccord\xe3ress", ), 'false' => array( // false is a column with no character set (ie, a number column)