WordPress.org

Make WordPress Core


Ignore:
Timestamp:
10/11/2017 12:09:47 AM (2 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/src/wp-includes/wp-db.php

    r41789 r41820  
    14801480            $socket  = null;
    14811481            $is_ipv6 = false;
    1482            
     1482
    14831483            if ( $host_data = $this->parse_db_host( $this->dbhost ) ) {
    14841484                list( $host, $port, $socket, $is_ipv6 ) = $host_data;
     
    16221622        }
    16231623
     1624        $host = '';
    16241625        foreach ( array( 'host', 'port', 'socket' ) as $component ) {
    1625             if ( array_key_exists( $component, $matches ) ) {
    1626                 $$component = $matches[$component];
     1626            if ( ! empty( $matches[ $component ] ) ) {
     1627                $$component = $matches[ $component ];
    16271628            }
    16281629        }
Note: See TracChangeset for help on using the changeset viewer.