WordPress.org

Make WordPress Core


Ignore:
Timestamp:
08/24/2015 12:18:49 AM (6 years ago)
Author:
pento
Message:

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

Props dustinbolton for the fix.

Fixes #33470.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/db.php

    r33259 r33718  
    527527    function data_get_table_from_query() {
    528528        $table = 'a_test_table_name';
    529         $db_table = '`a_test_db`.`another_test_table`';
     529        $more_tables = array(
     530            // table_name => expected_value
     531            '`a_test_db`.`another_test_table`' => 'a_test_db.another_test_table',
     532            'a-test-with-dashes'               => 'a-test-with-dashes',
     533        );
    530534
    531535        $queries = array(
     
    637641        $querycount = count( $queries );
    638642        for ( $ii = 0; $ii < $querycount; $ii++ ) {
    639             $db_query = str_replace( $table, $db_table, $queries[ $ii ] );
    640             $expected_db_table = str_replace( '`', '', $db_table );
     643            foreach ( $more_tables as $name => $expected_name ) {
     644                $new_query = str_replace( $table, $name, $queries[ $ii ] );
     645                $queries[] = array( $new_query, $expected_name );
     646            }
    641647
    642648            $queries[ $ii ] = array( $queries[ $ii ], $table );
    643             $queries[] = array( $db_query, $expected_db_table );
    644649        }
    645650        return $queries;
Note: See TracChangeset for help on using the changeset viewer.