Index: src/wp-includes/wp-db.php
--- src/wp-includes/wp-db.php
+++ src/wp-includes/wp-db.php
@@ -1892,6 +1892,9 @@
 			}
 		}

+		// MySQLi port cannot be a string; must be null or an integer.
+		$port = $port ? absint( $port ) : null;
+
 		return array( $host, $port, $socket, $is_ipv6 );
 	}

