mirror of
https://github.com/WordPress/WordPress.git
synced 2025-01-16 21:31:22 +01:00
WPDB: Fix the parsing of sockets which contain colons within the socket name (used on some cloud providers).
Props natacado. Merges [42226] to the 4.9 branch. Fixes #42634 for 4.9. Built from https://develop.svn.wordpress.org/branches/4.9@42229 git-svn-id: http://core.svn.wordpress.org/branches/4.9@42058 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
6dc1dd28f5
commit
68cb5b6f05
@ -4,7 +4,7 @@
|
||||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '4.9.1-alpha-42223';
|
||||
$wp_version = '4.9.1-alpha-42229';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
@ -1643,14 +1643,21 @@ class wpdb {
|
||||
$socket = null;
|
||||
$is_ipv6 = false;
|
||||
|
||||
// First peel off the socket parameter from the right, if it exists.
|
||||
$socket_pos = strpos( $host, ':/' );
|
||||
if ( $socket_pos !== false ) {
|
||||
$socket = substr( $host, $socket_pos + 1 );
|
||||
$host = substr( $host, 0, $socket_pos );
|
||||
}
|
||||
|
||||
// We need to check for an IPv6 address first.
|
||||
// An IPv6 address will always contain at least two colons.
|
||||
if ( substr_count( $host, ':' ) > 1 ) {
|
||||
$pattern = '#^(?:\[)?(?<host>[0-9a-fA-F:]+)(?:\]:(?<port>[\d]+))?(?:/(?<socket>.+))?#';
|
||||
$pattern = '#^(?:\[)?(?<host>[0-9a-fA-F:]+)(?:\]:(?<port>[\d]+))?#';
|
||||
$is_ipv6 = true;
|
||||
} else {
|
||||
// We seem to be dealing with an IPv4 address.
|
||||
$pattern = '#^(?<host>[^:/]*)(?::(?<port>[\d]+))?(?::(?<socket>.+))?#';
|
||||
$pattern = '#^(?<host>[^:/]*)(?::(?<port>[\d]+))?#';
|
||||
}
|
||||
|
||||
$matches = array();
|
||||
@ -1662,7 +1669,7 @@ class wpdb {
|
||||
}
|
||||
|
||||
$host = '';
|
||||
foreach ( array( 'host', 'port', 'socket' ) as $component ) {
|
||||
foreach ( array( 'host', 'port' ) as $component ) {
|
||||
if ( ! empty( $matches[ $component ] ) ) {
|
||||
$$component = $matches[ $component ];
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user