Make WordPress Core


Ignore:
Timestamp:
12/02/2014 02:59:36 AM (10 years ago)
Author:
pento
Message:

WPDB: When looking up the character set for a table or column, make sure we send the table name to MySQL in the correct case, as MySQL can be configured with case sensitive table names.

Fixes #30538.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/wp-db.php

    r30677 r30699  
    21652165     */
    21662166    protected function get_table_charset( $table ) {
    2167         $table = strtolower( $table );
     2167        $tablekey = strtolower( $table );
    21682168
    21692169        /**
     
    21832183        }
    21842184
    2185         if ( isset( $this->table_charset[ $table ] ) ) {
    2186             return $this->table_charset[ $table ];
     2185        if ( isset( $this->table_charset[ $tablekey ] ) ) {
     2186            return $this->table_charset[ $tablekey ];
    21872187        }
    21882188
     
    21972197        }
    21982198
    2199         $this->col_meta[ $table ] = $columns;
     2199        $this->col_meta[ $tablekey ] = $columns;
    22002200
    22012201        foreach ( $columns as $column ) {
     
    22092209            // A binary/blob means the whole query gets treated like this.
    22102210            if ( in_array( strtoupper( $type ), array( 'BINARY', 'VARBINARY', 'TINYBLOB', 'MEDIUMBLOB', 'BLOB', 'LONGBLOB' ) ) ) {
    2211                 $this->table_charset[ $table ] = 'binary';
     2211                $this->table_charset[ $tablekey ] = 'binary';
    22122212                return 'binary';
    22132213            }
     
    22432243        }
    22442244
    2245         $this->table_charset[ $table ] = $charset;
     2245        $this->table_charset[ $tablekey ] = $charset;
    22462246        return $charset;
    22472247    }
     
    22592259     */
    22602260    protected function get_col_charset( $table, $column ) {
    2261         $table = strtolower( $table );
    2262         $column = strtolower( $column );
     2261        $tablekey = strtolower( $table );
     2262        $columnkey = strtolower( $column );
    22632263
    22642264        /**
     
    22842284        }
    22852285
    2286         if ( empty( $this->table_charset[ $table ] ) ) {
     2286        if ( empty( $this->table_charset[ $tablekey ] ) ) {
    22872287            // This primes column information for us.
    22882288            $table_charset = $this->get_table_charset( $table );
     
    22932293
    22942294        // If still no column information, return the table charset.
    2295         if ( empty( $this->col_meta[ $table ] ) ) {
    2296             return $this->table_charset[ $table ];
     2295        if ( empty( $this->col_meta[ $tablekey ] ) ) {
     2296            return $this->table_charset[ $tablekey ];
    22972297        }
    22982298
    22992299        // If this column doesn't exist, return the table charset.
    2300         if ( empty( $this->col_meta[ $table ][ $column ] ) ) {
    2301             return $this->table_charset[ $table ];
     2300        if ( empty( $this->col_meta[ $tablekey ][ $columnkey ] ) ) {
     2301            return $this->table_charset[ $tablekey ];
    23022302        }
    23032303
    23042304        // Return false when it's not a string column.
    2305         if ( empty( $this->col_meta[ $table ][ $column ]->Collation ) ) {
     2305        if ( empty( $this->col_meta[ $tablekey ][ $columnkey ]->Collation ) ) {
    23062306            return false;
    23072307        }
    23082308
    2309         list( $charset ) = explode( '_', $this->col_meta[ $table ][ $column ]->Collation );
     2309        list( $charset ) = explode( '_', $this->col_meta[ $tablekey ][ $columnkey ]->Collation );
    23102310        return $charset;
    23112311    }
Note: See TracChangeset for help on using the changeset viewer.