Make WordPress Core

Ticket #32090: wp-db.diff

File wp-db.diff, 2.3 KB (added by willstedt, 10 years ago)

Patch to fix the bug #32090 - also fixes the lacking support for UTF8 characters in schema names, as such naming is allowed ackording to https://dev.mysql.com/doc/refman/5.5/en/identifiers.html

  • wp-includes/wp-db.php

    diff --git wp-includes/wp-db.php wp-includes/wp-db.php
    index 0bd7a18..2bf27f7 100644
    class wpdb { 
    22742274                        return $this->table_charset[ $tablekey ];
    22752275                }
    22762276
    2277                 $charsets = $columns = array();
    2278                 $results = $this->get_results( "SHOW FULL COLUMNS FROM `$table`" );
     2277                $charsets = $columns = array();         
     2278                $table_parts = explode('.', $table);
     2279                $table_parts = array_map(function($var) { return "`".$var."`"; },$table_parts);
     2280                $table = implode(".",$table_parts);
     2281
     2282                $results = $this->get_results( "SHOW FULL COLUMNS FROM $table" );
    22792283                if ( ! $results ) {
    22802284                        return new WP_Error( 'wpdb_get_table_charset_failure' );
    22812285                }
    class wpdb { 
    27992803                $query = preg_replace( '/\((?!\s*select)[^(]*?\)/is', '()', substr( $query, 0, 1000 ) );
    28002804
    28012805                // Quickly match most common queries.
    2802                 if ( preg_match( '/^\s*(?:'
     2806                if ( preg_match( '/(*UTF8)^\s*(?:'
    28032807                                . 'SELECT.*?\s+FROM'
    28042808                                . '|INSERT(?:\s+LOW_PRIORITY|\s+DELAYED|\s+HIGH_PRIORITY)?(?:\s+IGNORE)?(?:\s+INTO)?'
    28052809                                . '|REPLACE(?:\s+LOW_PRIORITY|\s+DELAYED)?(?:\s+INTO)?'
    28062810                                . '|UPDATE(?:\s+LOW_PRIORITY)?(?:\s+IGNORE)?'
    28072811                                . '|DELETE(?:\s+LOW_PRIORITY|\s+QUICK|\s+IGNORE)*(?:\s+FROM)?'
    2808                                 . ')\s+`?([\w-]+)`?/is', $query, $maybe ) ) {
     2812                                . ')\s+`?([[:alnum:]-._$]+)`?/uis', $query, $maybe ) ) {
    28092813                        return $maybe[1];
    28102814                }
    28112815
    28122816                // SHOW TABLE STATUS and SHOW TABLES
    2813                 if ( preg_match( '/^\s*(?:'
     2817                if ( preg_match( '/(*UTF8)^\s*(?:'
    28142818                                . 'SHOW\s+TABLE\s+STATUS.+(?:LIKE\s+|WHERE\s+Name\s*=\s*)'
    28152819                                . '|SHOW\s+(?:FULL\s+)?TABLES.+(?:LIKE\s+|WHERE\s+Name\s*=\s*)'
    2816                                 . ')\W([\w-]+)\W/is', $query, $maybe ) ) {
     2820                                . ')\W([[:alnum:]-._$]+)\W/uis', $query, $maybe ) ) {
    28172821                        return $maybe[1];
    28182822                }
    28192823
    28202824                // Big pattern for the rest of the table-related queries.
    2821                 if ( preg_match( '/^\s*(?:'
     2825                if ( preg_match( '/(*UTF8)^\s*(?:'
    28222826                                . '(?:EXPLAIN\s+(?:EXTENDED\s+)?)?SELECT.*?\s+FROM'
    28232827                                . '|DESCRIBE|DESC|EXPLAIN|HANDLER'
    28242828                                . '|(?:LOCK|UNLOCK)\s+TABLE(?:S)?'
    class wpdb { 
    28322836                                . '|LOAD\s+DATA.*INFILE.*INTO\s+TABLE'
    28332837                                . '|(?:GRANT|REVOKE).*ON\s+TABLE'
    28342838                                . '|SHOW\s+(?:.*FROM|.*TABLE)'
    2835                                 . ')\s+\(*\s*`?([\w-]+)`?\s*\)*/is', $query, $maybe ) ) {
     2839                                . ')\s+\(*\s*`?([[:alnum:]-._$]+)`?\s*\)*/uis', $query, $maybe ) ) {
    28362840                        return $maybe[1];
    28372841                }
    28382842