WPDB: `::strip_text_from_query()` doesn't pass a length to `::strip_invalid_text()`, which was causing queries to fail when they contained characters that needed to be sanity checked by MySQL.
Props dd32, mdawaffe, pento. Merges [33310] to the 4.1 branch. See #32279. Built from https://develop.svn.wordpress.org/branches/4.1@33479 git-svn-id: http://core.svn.wordpress.org/branches/4.1@33446 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
0f529b177c
commit
50e855410b
|
@ -2570,8 +2570,13 @@ class wpdb {
|
||||||
|
|
||||||
if ( is_array( $value['length'] ) ) {
|
if ( is_array( $value['length'] ) ) {
|
||||||
$length = $value['length']['length'];
|
$length = $value['length']['length'];
|
||||||
|
$truncate_by_byte_length = 'byte' === $value['length']['type'];
|
||||||
} else {
|
} else {
|
||||||
$length = false;
|
$length = false;
|
||||||
|
// Since we have no length, we'll never truncate.
|
||||||
|
// Initialize the variable to false. true would take us
|
||||||
|
// through an unnecessary (for this case) codepath below.
|
||||||
|
$truncate_by_byte_length = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// There's no charset to work with.
|
// There's no charset to work with.
|
||||||
|
@ -2584,8 +2589,6 @@ class wpdb {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$truncate_by_byte_length = 'byte' === $value['length']['type'];
|
|
||||||
|
|
||||||
$needs_validation = true;
|
$needs_validation = true;
|
||||||
if (
|
if (
|
||||||
// latin1 can store any byte sequence
|
// latin1 can store any byte sequence
|
||||||
|
@ -2659,7 +2662,12 @@ class wpdb {
|
||||||
$charset = $value['charset'];
|
$charset = $value['charset'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( is_array( $value['length'] ) ) {
|
||||||
$queries[ $col ] = $this->prepare( "CONVERT( LEFT( CONVERT( %s USING $charset ), %.0f ) USING {$this->charset} )", $value['value'], $value['length']['length'] );
|
$queries[ $col ] = $this->prepare( "CONVERT( LEFT( CONVERT( %s USING $charset ), %.0f ) USING {$this->charset} )", $value['value'], $value['length']['length'] );
|
||||||
|
} else if ( 'binary' !== $charset ) {
|
||||||
|
// If we don't have a length, there's no need to convert binary - it will always return the same result.
|
||||||
|
$queries[ $col ] = $this->prepare( "CONVERT( CONVERT( %s USING $charset ) USING {$this->charset} )", $value['value'] );
|
||||||
|
}
|
||||||
|
|
||||||
unset( $data[ $col ]['db'] );
|
unset( $data[ $col ]['db'] );
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue