Index: wp-includes/wp-db.php
===================================================================
--- wp-includes/wp-db.php	(revision 31181)
+++ wp-includes/wp-db.php	(working copy)
@@ -1417,11 +1417,7 @@
 				}
 			}
 
-			if ( WP_DEBUG ) {
-				mysqli_real_connect( $this->dbh, $host, $this->dbuser, $this->dbpassword, null, $port, $socket, $client_flags );
-			} else {
-				@mysqli_real_connect( $this->dbh, $host, $this->dbuser, $this->dbpassword, null, $port, $socket, $client_flags );
-			}
+			$this->mysqli_real_connect( $host, $port, $socket, $client_flags );
 
 			if ( $this->dbh->connect_errno ) {
 				$this->dbh = null;
@@ -1447,11 +1443,7 @@
 				}
 			}
 		} else {
-			if ( WP_DEBUG ) {
-				$this->dbh = mysql_connect( $this->dbhost, $this->dbuser, $this->dbpassword, $new_link, $client_flags );
-			} else {
-				$this->dbh = @mysql_connect( $this->dbhost, $this->dbuser, $this->dbpassword, $new_link, $client_flags );
-			}
+			$this->mysql_connect( $new_link, $client_flags );
 		}
 
 		if ( ! $this->dbh && $allow_bail ) {
@@ -1489,6 +1481,40 @@
 	}
 
 	/**
+	 * A mysqli_real_connect abstraction method
+	 *
+	 * @since 4.2.0
+	 *
+	 * @param string $host         host name or an IP address
+	 * @param int    $port         Specifies the port number to attempt to connect to the MySQL server.
+	 * @param string $socket       Specifies the socket or named pipe that should be used.
+	 * @param int    $client_flags Sets different connection options
+	 */
+	public function mysqli_real_connect( $host, $port, $socket, $client_flags ) {
+		if ( WP_DEBUG ) {
+			mysqli_real_connect( $this->dbh, $host, $this->dbuser, $this->dbpassword, null, $port, $socket, $client_flags );
+		} else {
+			@mysqli_real_connect( $this->dbh, $host, $this->dbuser, $this->dbpassword, null, $port, $socket, $client_flags );
+		}
+	}
+
+	/**
+	 * A mysql_connect abstraction method
+	 *
+	 * @since 4.2.0
+	 *
+	 * @param bool  $new_link     Is this a new link?
+	 * @param int    $client_flags Sets different connection options
+	 */
+	public function mysql_connect( $new_link, $client_flags ) {
+		if ( WP_DEBUG ) {
+			$this->dbh = mysql_connect( $this->dbhost, $this->dbuser, $this->dbpassword, $new_link, $client_flags );
+		} else {
+			$this->dbh = @mysql_connect( $this->dbhost, $this->dbuser, $this->dbpassword, $new_link, $client_flags );
+		}
+	}
+
+	/**
 	 * Check that the connection to the database is still up. If not, try to reconnect.
 	 *
 	 * If this function is unable to reconnect, it will forcibly die, or if after the
