mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-22 17:18:32 +01:00
WPDB: When deciding if a query needs extra sanity checking based on collation, we can quickly return if it's a query that will never return user data.
Fixes #32029. Built from https://develop.svn.wordpress.org/trunk@32232 git-svn-id: http://core.svn.wordpress.org/trunk@32206 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
6bdd0658be
commit
6f38333ab2
@ -4,7 +4,7 @@
|
||||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '4.2-RC2-32231';
|
||||
$wp_version = '4.2-RC2-32232';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
@ -2399,20 +2399,32 @@ class wpdb {
|
||||
return true;
|
||||
}
|
||||
|
||||
// We don't need to check the collation for queries that don't read data.
|
||||
$query = ltrim( $query, "\r\n\t (" );
|
||||
if ( preg_match( '/^(?:SHOW|DESCRIBE|DESC|EXPLAIN)\s/i', $query ) ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$table = $this->get_table_from_query( $query );
|
||||
if ( ! $table ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->checking_collation = true;
|
||||
$this->get_table_charset( $table );
|
||||
$collation = $this->get_table_charset( $table );
|
||||
$this->checking_collation = false;
|
||||
|
||||
// Tables with no collation, or latin1 only, don't need extra checking.
|
||||
if ( false === $collation || 'latin1' === $collation ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$table = strtolower( $table );
|
||||
if ( empty( $this->col_meta[ $table ] ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// If any of the columns don't have one of these collations, it needs more sanity checking.
|
||||
foreach( $this->col_meta[ $table ] as $col ) {
|
||||
if ( empty( $col->Collation ) ) {
|
||||
continue;
|
||||
|
Loading…
Reference in New Issue
Block a user