use mysqli_result;
use IP;
use stdClass;
+use Wikimedia\AtEase\AtEase;
/**
* Database abstraction object for PHP extension mysqli.
* @ingroup Database
* @since 1.22
* @see Database
+ * @phan-file-suppress PhanParamSignatureMismatch resource vs mysqli_result
*/
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;
}
/**
);
}
- // 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 );
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 );
}