jenkins-bot has submitted this change and it was merged.

Change subject: Make MySQLi work with non-standard socket
......................................................................


Make MySQLi work with non-standard socket

MySQLi needs to specify the socket location as a parameter, and not as part
of the hostname.

Split the socket out of the hostname if it contains *one* colon (IPv6 safe)
after checking for the port number.

Bug: 65998
Change-Id: I66ee34e1029bc1630669bde4272d0eae9d3fd9f1
---
M includes/db/DatabaseMysqli.php
1 file changed, 10 insertions(+), 2 deletions(-)

Approvals:
  John Vandenberg: Looks good to me, but someone else must approve
  Legoktm: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/includes/db/DatabaseMysqli.php b/includes/db/DatabaseMysqli.php
index 2ce6307..a03c9aa 100644
--- a/includes/db/DatabaseMysqli.php
+++ b/includes/db/DatabaseMysqli.php
@@ -58,14 +58,22 @@
                }
 
                // Other than mysql_connect, mysqli_real_connect expects an 
explicit port
-               // parameter. So we need to parse the port out of $realServer
+               // and socket parameters. So we need to parse the port and 
socket out of
+               // $realServer
                $port = null;
+               $socket = null;
                $hostAndPort = IP::splitHostAndPort( $realServer );
                if ( $hostAndPort ) {
                        $realServer = $hostAndPort[0];
                        if ( $hostAndPort[1] ) {
                                $port = $hostAndPort[1];
                        }
+               } elseif ( substr_count( $realServer, ':' ) == 1 ) {
+                       // If we have a colon and something that's not a port 
number
+                       // inside the hostname, assume it's the socket location
+                       $hostAndSocket = explode( ':', $realServer );
+                       $realServer = $hostAndSocket[0];
+                       $socket = $hostAndSocket[1];
                }
 
                $connFlags = 0;
@@ -90,7 +98,7 @@
                $mysqli->options( MYSQLI_OPT_CONNECT_TIMEOUT, 3 );
 
                if ( $mysqli->real_connect( $realServer, $this->mUser,
-                       $this->mPassword, $this->mDBname, $port, null, 
$connFlags )
+                       $this->mPassword, $this->mDBname, $port, $socket, 
$connFlags )
                ) {
                        return $mysqli;
                }

-- 
To view, visit https://gerrit.wikimedia.org/r/136638
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I66ee34e1029bc1630669bde4272d0eae9d3fd9f1
Gerrit-PatchSet: 4
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Martineznovo <[email protected]>
Gerrit-Reviewer: Aaron Schulz <[email protected]>
Gerrit-Reviewer: BryanDavis <[email protected]>
Gerrit-Reviewer: John Vandenberg <[email protected]>
Gerrit-Reviewer: Legoktm <[email protected]>
Gerrit-Reviewer: MarkAHershberger <[email protected]>
Gerrit-Reviewer: Martineznovo <[email protected]>
Gerrit-Reviewer: Parent5446 <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to