Ticket #32090: 32090-37.patch
File 32090-37.patch, 2.7 KB (added by , 10 years ago) |
---|
-
branches/3.7/src/wp-includes/wp-db.php
1824 1824 } 1825 1825 1826 1826 $charsets = $columns = array(); 1827 $results = $this->get_results( "SHOW FULL COLUMNS FROM `$table`" ); 1827 1828 $table_parts = explode( '.', $table ); 1829 $table = '`' . implode( '`.`', $table_parts ) . '`'; 1830 $results = $this->get_results( "SHOW FULL COLUMNS FROM $table" ); 1828 1831 if ( ! $results ) { 1829 1832 return new WP_Error( 'wpdb_get_table_charset_failure' ); 1830 1833 } … … 2391 2394 . '|REPLACE(?:\s+LOW_PRIORITY|\s+DELAYED)?(?:\s+INTO)?' 2392 2395 . '|UPDATE(?:\s+LOW_PRIORITY)?(?:\s+IGNORE)?' 2393 2396 . '|DELETE(?:\s+LOW_PRIORITY|\s+QUICK|\s+IGNORE)*(?:\s+FROM)?' 2394 . ')\s+ `?([\w-]+)`?/is', $query, $maybe ) ) {2395 return $maybe[1];2397 . ')\s+((?:[0-9a-zA-Z$_.`]|[\xC2-\xDF][\x80-\xBF])+)/is', $query, $maybe ) ) { 2398 return str_replace( '`', '', $maybe[1] ); 2396 2399 } 2397 2400 2398 2401 // SHOW TABLE STATUS and SHOW TABLES 2399 2402 if ( preg_match( '/^\s*(?:' 2400 2403 . 'SHOW\s+TABLE\s+STATUS.+(?:LIKE\s+|WHERE\s+Name\s*=\s*)' 2401 2404 . '|SHOW\s+(?:FULL\s+)?TABLES.+(?:LIKE\s+|WHERE\s+Name\s*=\s*)' 2402 . ')\W( [\w-]+)\W/is', $query, $maybe ) ) {2403 return $maybe[1];2405 . ')\W((?:[0-9a-zA-Z$_.`]|[\xC2-\xDF][\x80-\xBF])+)\W/is', $query, $maybe ) ) { 2406 return str_replace( '`', '', $maybe[1] ); 2404 2407 } 2405 2408 2406 2409 // Big pattern for the rest of the table-related queries. … … 2418 2421 . '|LOAD\s+DATA.*INFILE.*INTO\s+TABLE' 2419 2422 . '|(?:GRANT|REVOKE).*ON\s+TABLE' 2420 2423 . '|SHOW\s+(?:.*FROM|.*TABLE)' 2421 . ')\s+\(*\s* `?([\w-]+)`?\s*\)*/is', $query, $maybe ) ) {2422 return $maybe[1];2424 . ')\s+\(*\s*((?:[0-9a-zA-Z$_.`]|[\xC2-\xDF][\x80-\xBF])+)\s*\)*/is', $query, $maybe ) ) { 2425 return str_replace( '`', '', $maybe[1] ); 2423 2426 } 2424 2427 2425 2428 return false; -
branches/3.7/tests/phpunit/tests/db.php
290 290 */ 291 291 function data_get_table_from_query() { 292 292 $table = 'a_test_table_name'; 293 $db_table = '`a_test_db`.`another_test_table`'; 293 294 294 295 $queries = array( 295 296 // Basic … … 392 393 "SHOW INDEX FROM $table", 393 394 ); 394 395 395 foreach ( $queries as &$query ) { 396 $query = array( $query, $table ); 396 $querycount = count( $queries ); 397 for ( $ii = 0; $ii < $querycount; $ii++ ) { 398 $db_query = str_replace( $table, $db_table, $queries[ $ii ] ); 399 $expected_db_table = str_replace( '`', '', $db_table ); 400 401 $queries[ $ii ] = array( $queries[ $ii ], $table ); 402 $queries[] = array( $db_query, $expected_db_table ); 397 403 } 398 404 return $queries; 399 405 }