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.


Built from https://develop.svn.wordpress.org/trunk@41820


git-svn-id: http://core.svn.wordpress.org/trunk@41654 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Gary Pendergast 2017-10-11 00:10:47 +00:00
parent 3609d0c4c5
commit fd247bc2e4
2 changed files with 5 additions and 4 deletions

View File

@ -4,7 +4,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '4.9-beta1-41819'; $wp_version = '4.9-beta1-41820';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.

View File

@ -1621,9 +1621,10 @@ class wpdb {
return false; return false;
} }
$host = '';
foreach ( array( 'host', 'port', 'socket' ) as $component ) { foreach ( array( 'host', 'port', 'socket' ) as $component ) {
if ( array_key_exists( $component, $matches ) ) { if ( ! empty( $matches[ $component ] ) ) {
$$component = $matches[$component]; $$component = $matches[ $component ];
} }
} }