Make WordPress Core


Ignore:
Timestamp:
10/11/2017 12:09:47 AM (6 years ago)
Author:
pento
Message:

Database: When parsing the host, leave the port and socket as null if they're not defined.

This fixes a change in behaviour introduced by [41629].

The host is set to an empty string when it isn't defined, this continues existing behaviour. In particular, the mysqli library treats a null host as being the same as localhost, which is not always the intended behaviour.

Props birgire, markjaquith, pento.
Fixes #41722.

File:
1 edited

Legend:

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

    r41662 r41820  
    12091209            list( $parsed_host, $parsed_port, $parsed_socket, $parsed_is_ipv6 ) = $data;
    12101210
    1211             $this->assertEquals( $host, $parsed_host );
    1212             $this->assertEquals( $port, $parsed_port );
    1213             $this->assertEquals( $socket, $parsed_socket );
    1214             $this->assertEquals( $is_ipv6, $parsed_is_ipv6 );
     1211            $this->assertSame( $host, $parsed_host );
     1212            $this->assertSame( $port, $parsed_port );
     1213            $this->assertSame( $socket, $parsed_socket );
     1214            $this->assertSame( $is_ipv6, $parsed_is_ipv6 );
    12151215        }
    12161216    }
     
    12211221                '',    // DB_HOST
    12221222                false, // Expect parse_db_host to bail for this hostname
    1223                 null,  // Parsed host
     1223                '',    // Parsed host
    12241224                null,  // Parsed port
    12251225                null,  // Parsed socket
     
    12291229                ':3306',
    12301230                false,
    1231                 null,
     1231                '',
    12321232                '3306',
    12331233                null,
     
    12371237                ':/tmp/mysql.sock',
    12381238                false,
    1239                 null,
     1239                '',
    12401240                null,
    12411241                '/tmp/mysql.sock',
Note: See TracChangeset for help on using the changeset viewer.