WordPress.org

Make WordPress Core


Ignore:
Timestamp:
05/23/2016 06:11:32 PM (5 years ago)
Author:
ocean90
Message:

Database: Support backticks around field names when parsing a query for the field type.

Avoids an undefined index PHP warning by dbDelta().

Props davidmosterd, ocean90.
See #20263.

File:
1 edited

Legend:

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

    r37525 r37538  
    465465            ), $result );
    466466    }
     467
     468    /**
     469     * @ticket 20263
     470     */
     471    function test_query_with_backticks_does_not_throw_an_undefined_index_warning() {
     472        global $wpdb;
     473
     474        $schema = "
     475            CREATE TABLE {$wpdb->prefix}dbdelta_test2 (
     476                `id` bigint(20) NOT NULL AUTO_INCREMENT,
     477                `column_1` varchar(255) NOT NULL,
     478                PRIMARY KEY  (id),
     479                KEY compound_key (id,column_1)
     480            )
     481        ";
     482
     483        $wpdb->query( $schema );
     484
     485        $updates = dbDelta( $schema, false );
     486
     487        $wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}dbdelta_test2" );
     488
     489        $this->assertEmpty( $updates );
     490    }
    467491}
Note: See TracChangeset for help on using the changeset viewer.