Make WordPress Core


Ignore:
Timestamp:
09/10/2015 07:08:35 AM (9 years ago)
Author:
pento
Message:

WPDB: get_table_from_query() didn't find table names with hyphens in them.

Merge of [33718] to the 3.9 branch.

Props dustinbolton, pento.

See #33470.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/3.9/tests/phpunit/tests/db.php

    r32414 r33995  
    393393    function data_get_table_from_query() {
    394394        $table = 'a_test_table_name';
    395         $db_table = '`a_test_db`.`another_test_table`';
     395        $more_tables = array(
     396            // table_name => expected_value
     397            '`a_test_db`.`another_test_table`' => 'a_test_db.another_test_table',
     398            'a-test-with-dashes'               => 'a-test-with-dashes',
     399        );
    396400
    397401        $queries = array(
     
    498502        $querycount = count( $queries );
    499503        for ( $ii = 0; $ii < $querycount; $ii++ ) {
    500             $db_query = str_replace( $table, $db_table, $queries[ $ii ] );
    501             $expected_db_table = str_replace( '`', '', $db_table );
     504            foreach ( $more_tables as $name => $expected_name ) {
     505                $new_query = str_replace( $table, $name, $queries[ $ii ] );
     506                $queries[] = array( $new_query, $expected_name );
     507            }
    502508
    503509            $queries[ $ii ] = array( $queries[ $ii ], $table );
    504             $queries[] = array( $db_query, $expected_db_table );
    505510        }
    506511        return $queries;
Note: See TracChangeset for help on using the changeset viewer.