Make WordPress Core

Changeset 34655


Ignore:
Timestamp:
09/28/2015 01:16:29 AM (9 years ago)
Author:
pento
Message:

WPDB: Make sure we don't run sanity checks on DB dropins.

Previously, we'd run the sanity checks if is_mysql was not set to false. This caused problems for DB drop-ins that didn't define is_mysql at all. Instead, we can just check if is_mysql is empty().

Also fix some unit tests that accidently ran correctly because of the strict false === comparison.

Fixes #33501.

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/wp-db.php

    r34529 r34655  
    24152415
    24162416        // Skip this entirely if this isn't a MySQL database.
    2417         if ( false === $this->is_mysql ) {
     2417        if ( empty( $this->is_mysql ) ) {
    24182418            return false;
    24192419        }
     
    24642464
    24652465        // Skip this entirely if this isn't a MySQL database.
    2466         if ( false === $this->is_mysql ) {
     2466        if ( empty( $this->is_mysql ) ) {
    24672467            return false;
    24682468        }
  • trunk/tests/phpunit/includes/utils.php

    r34215 r34655  
    381381        $this->dbh = $wpdb->dbh;
    382382        $this->use_mysqli = $wpdb->use_mysqli;
     383        $this->is_mysql = $wpdb->is_mysql;
    383384        $this->ready = true;
    384385        $this->field_types = $wpdb->field_types;
  • trunk/tests/phpunit/tests/db/charset.php

    r33425 r34655  
    639639
    640640    /**
     641     * @dataProvider data_test_get_column_charset
     642     * @ticket 33501
     643     */
     644    function test_get_column_charset_is_mysql_undefined( $drop, $create, $table, $columns ) {
     645        self::$_wpdb->query( $drop );
     646
     647        if ( ! self::$_wpdb->has_cap( 'utf8mb4' ) && preg_match( '/utf8mb[34]/i', $create ) ) {
     648            $this->markTestSkipped( "This version of MySQL doesn't support utf8mb4." );
     649            return;
     650        }
     651
     652        unset( self::$_wpdb->is_mysql );
     653
     654        self::$_wpdb->query( $create );
     655
     656        $columns = array_keys( $columns );
     657        foreach ( $columns as $column => $charset ) {
     658            $this->assertEquals( false, self::$_wpdb->get_col_charset( $table, $column ) );
     659        }
     660
     661        self::$_wpdb->query( $drop );
     662
     663        self::$_wpdb->is_mysql = true;
     664    }
     665
     666    /**
    641667     * @ticket 21212
    642668     */
Note: See TracChangeset for help on using the changeset viewer.