Merge "Provide command to adjust phpunit.xml for code coverage"
[lhc/web/wiklou.git] / includes / libs / rdbms / database / DatabaseMysqli.php
index 2f9abcf..b9a1af6 100644 (file)
@@ -26,6 +26,7 @@ use mysqli;
 use mysqli_result;
 use IP;
 use stdClass;
+use Wikimedia\AtEase\AtEase;
 
 /**
  * Database abstraction object for PHP extension mysqli.
@@ -33,6 +34,7 @@ use stdClass;
  * @ingroup Database
  * @since 1.22
  * @see Database
+ * @phan-file-suppress PhanParamSignatureMismatch resource vs mysqli_result
  */
 class DatabaseMysqli extends DatabaseMysqlBase {
        /**
@@ -40,7 +42,11 @@ class DatabaseMysqli extends DatabaseMysqlBase {
         * @return mysqli_result|bool
         */
        protected function doQuery( $sql ) {
-               return $this->getBindingHandle()->query( $sql );
+               AtEase::suppressWarnings();
+               $res = $this->getBindingHandle()->query( $sql );
+               AtEase::restoreWarnings();
+
+               return $res;
        }
 
        /**
@@ -56,9 +62,14 @@ class DatabaseMysqli extends DatabaseMysqlBase {
                        );
                }
 
-               // Other than mysql_connect, mysqli_real_connect expects an explicit port
-               // and socket parameters. So we need to parse the port and socket out of
-               // $realServer
+               // Other than mysql_connect, mysqli_real_connect expects an explicit port number
+               // e.g. "localhost:1234" or "127.0.0.1:1234"
+               // or Unix domain socket path
+               // e.g. "localhost:/socket_path" or "localhost:/foo/bar:bar:bar"
+               // colons are known to be used by Google AppEngine,
+               // see <https://cloud.google.com/sql/docs/mysql/connect-app-engine>
+               //
+               // We need to parse the port or socket path out of $realServer
                $port = null;
                $socket = null;
                $hostAndPort = IP::splitHostAndPort( $realServer );
@@ -67,9 +78,9 @@ class DatabaseMysqli extends DatabaseMysqlBase {
                        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
+               } elseif ( substr_count( $realServer, ':/' ) == 1 ) {
+                       // If we have a colon slash instead of a colon and a port number
+                       // after the ip or hostname, assume it's the Unix domain socket path
                        list( $realServer, $socket ) = explode( ':', $realServer, 2 );
                }