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

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


Make MySQLi work with non-standard port

Other than mysql_connect, mysqli_real_connect expects an explicit
port parameter. So we need to parse the port out of $realServer. Note it
is not possible to just use $wgDBport, since that is set to 5432 as a
default and would break all existing sites using mysqli on standard port.

This change is IPv6 safe.

Bug: 58153
Change-Id: I58e690ef2803e205f324a142fbcbd96cc87510f1
---
M includes/db/DatabaseMysqli.php
1 file changed, 12 insertions(+), 1 deletion(-)

Approvals:
  MarkAHershberger: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/includes/db/DatabaseMysqli.php b/includes/db/DatabaseMysqli.php
index 7761abe..0ec5431 100644
--- a/includes/db/DatabaseMysqli.php
+++ b/includes/db/DatabaseMysqli.php
@@ -51,6 +51,17 @@
                                . " have you compiled PHP with the 
--with-mysqli option?\n" );
                }
 
+               // Other than mysql_connect, mysqli_real_connect expects an 
explicit port
+               // parameter. So we need to parse the port out of $realServer
+               $port = null;
+               $hostAndPort = IP::splitHostAndPort( $realServer );
+               if ( $hostAndPort ) {
+                       $realServer = $hostAndPort[0];
+                       if ( $hostAndPort[1] ) {
+                               $port = $hostAndPort[1];
+                       }
+               }
+
                $connFlags = 0;
                if ( $this->mFlags & DBO_SSL ) {
                        $connFlags |= MYSQLI_CLIENT_SSL;
@@ -70,7 +81,7 @@
                                usleep( 1000 );
                        }
                        if ( $mysqli->real_connect( $realServer, $this->mUser,
-                               $this->mPassword, $this->mDBname, null, null, 
$connFlags ) )
+                               $this->mPassword, $this->mDBname, $port, null, 
$connFlags ) )
                        {
                                return $mysqli;
                        }

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I58e690ef2803e205f324a142fbcbd96cc87510f1
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: REL1_22
Gerrit-Owner: Mglaser <gla...@hallowelt.biz>
Gerrit-Reviewer: Aaron Schulz <asch...@wikimedia.org>
Gerrit-Reviewer: MarkAHershberger <m...@nichework.com>
Gerrit-Reviewer: Parent5446 <tylerro...@gmail.com>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to