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
This commit is contained in:
Gary Pendergast 2015-04-22 15:01:25 +00:00
parent 4e067b0354
commit cc8a9824c5
2 changed files with 11 additions and 4 deletions

View File

@ -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'] );
}
}

View File

@ -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)