Ticket #32090: 32090-40.patch
File 32090-40.patch, 2.7 KB (added by , 10 years ago) |
---|
-
branches/4.0/src/wp-includes/wp-db.php
2245 2245 } 2246 2246 2247 2247 $charsets = $columns = array(); 2248 $results = $this->get_results( "SHOW FULL COLUMNS FROM `$table`" ); 2248 2249 $table_parts = explode( '.', $table ); 2250 $table = '`' . implode( '`.`', $table_parts ) . '`'; 2251 $results = $this->get_results( "SHOW FULL COLUMNS FROM $table" ); 2249 2252 if ( ! $results ) { 2250 2253 return new WP_Error( 'wpdb_get_table_charset_failure' ); 2251 2254 } … … 2818 2821 . '|REPLACE(?:\s+LOW_PRIORITY|\s+DELAYED)?(?:\s+INTO)?' 2819 2822 . '|UPDATE(?:\s+LOW_PRIORITY)?(?:\s+IGNORE)?' 2820 2823 . '|DELETE(?:\s+LOW_PRIORITY|\s+QUICK|\s+IGNORE)*(?:\s+FROM)?' 2821 . ')\s+ `?([\w-]+)`?/is', $query, $maybe ) ) {2822 return $maybe[1];2824 . ')\s+((?:[0-9a-zA-Z$_.`]|[\xC2-\xDF][\x80-\xBF])+)/is', $query, $maybe ) ) { 2825 return str_replace( '`', '', $maybe[1] ); 2823 2826 } 2824 2827 2825 2828 // SHOW TABLE STATUS and SHOW TABLES 2826 2829 if ( preg_match( '/^\s*(?:' 2827 2830 . 'SHOW\s+TABLE\s+STATUS.+(?:LIKE\s+|WHERE\s+Name\s*=\s*)' 2828 2831 . '|SHOW\s+(?:FULL\s+)?TABLES.+(?:LIKE\s+|WHERE\s+Name\s*=\s*)' 2829 . ')\W( [\w-]+)\W/is', $query, $maybe ) ) {2830 return $maybe[1];2832 . ')\W((?:[0-9a-zA-Z$_.`]|[\xC2-\xDF][\x80-\xBF])+)\W/is', $query, $maybe ) ) { 2833 return str_replace( '`', '', $maybe[1] ); 2831 2834 } 2832 2835 2833 2836 // Big pattern for the rest of the table-related queries. … … 2845 2848 . '|LOAD\s+DATA.*INFILE.*INTO\s+TABLE' 2846 2849 . '|(?:GRANT|REVOKE).*ON\s+TABLE' 2847 2850 . '|SHOW\s+(?:.*FROM|.*TABLE)' 2848 . ')\s+\(*\s* `?([\w-]+)`?\s*\)*/is', $query, $maybe ) ) {2849 return $maybe[1];2851 . ')\s+\(*\s*((?:[0-9a-zA-Z$_.`]|[\xC2-\xDF][\x80-\xBF])+)\s*\)*/is', $query, $maybe ) ) { 2852 return str_replace( '`', '', $maybe[1] ); 2850 2853 } 2851 2854 2852 2855 return false; -
branches/4.0/tests/phpunit/tests/db.php
491 491 */ 492 492 function data_get_table_from_query() { 493 493 $table = 'a_test_table_name'; 494 $db_table = '`a_test_db`.`another_test_table`'; 494 495 495 496 $queries = array( 496 497 // Basic … … 593 594 "SHOW INDEX FROM $table", 594 595 ); 595 596 596 foreach ( $queries as &$query ) { 597 $query = array( $query, $table ); 597 $querycount = count( $queries ); 598 for ( $ii = 0; $ii < $querycount; $ii++ ) { 599 $db_query = str_replace( $table, $db_table, $queries[ $ii ] ); 600 $expected_db_table = str_replace( '`', '', $db_table ); 601 602 $queries[ $ii ] = array( $queries[ $ii ], $table ); 603 $queries[] = array( $db_query, $expected_db_table ); 598 604 } 599 605 return $queries; 600 606 }