}
}
+ /**
+ * Connect via mysqli.
+ *
+ * This is exactly the same as mysqli_connect(), except that it accepts
+ * the port as part of the `$host`.
+ *
+ * @param string $host
+ * Ex: 'localhost', 'localhost:3307', '127.0.0.1:3307', '[::1]', '[::1]:3307'.
+ * @param string $username
+ * @param string $password
+ * @param string $database
+ * @return \mysqli
+ */
+ protected function connect($host, $username, $password, $database = '') {
+ $hostParts = explode(':', $host);
+ if (count($hostParts) > 1 && strrpos($host, ']') !== strlen($host) - 1) {
+ $port = array_pop($hostParts);
+ $host = implode(':', $hostParts);
+ }
+ else {
+ $port = NULL;
+ }
+ $conn = @mysqli_connect($host, $username, $password, $database, $port);
+ return $conn;
+ }
+
/**
* Check everything except the database.
*/
ts("MySQL support not included in PHP."),
));
+ // Check for XML support
+ $this->requireFunction('simplexml_load_file', array(
+ ts("PHP Configuration"),
+ ts("SimpleXML support"),
+ ts("SimpleXML support not included in PHP."),
+ ));
+
// Check for JSON support
$this->requireFunction('json_encode', array(
ts("PHP Configuration"),
*/
public function requireMysqlConnection($server, $username, $password, $testDetails) {
$this->testing($testDetails);
- $this->conn = @mysqli_connect($server, $username, $password);
+ $this->conn = $this->connect($server, $username, $password);
if ($this->conn) {
return TRUE;
*/
public function requireMySQLServer($server, $testDetails) {
$this->testing($testDetails);
- $conn = @mysqli_connect($server, NULL, NULL);
+ $conn = $this->connect($server, NULL, NULL);
if ($conn || mysqli_connect_errno() < 2000) {
return TRUE;
*/
public function requireMySQLInnoDB($server, $username, $password, $database, $testDetails) {
$this->testing($testDetails);
- $conn = @mysqli_connect($server, $username, $password);
+ $conn = $this->connect($server, $username, $password);
if (!$conn) {
$testDetails[2] .= ' ' . ts("Could not determine if MySQL has InnoDB support. Assuming no.");
$this->error($testDetails);
*/
public function requireMySQLTempTables($server, $username, $password, $database, $testDetails) {
$this->testing($testDetails);
- $conn = @mysqli_connect($server, $username, $password);
+ $conn = $this->connect($server, $username, $password);
if (!$conn) {
$testDetails[2] = ts('Could not login to the database.');
$this->error($testDetails);
*/
public function requireMySQLTrigger($server, $username, $password, $database, $testDetails) {
$this->testing($testDetails);
- $conn = @mysqli_connect($server, $username, $password);
+ $conn = $this->connect($server, $username, $password);
if (!$conn) {
$testDetails[2] = ts('Could not login to the database.');
$this->error($testDetails);
*/
public function requireMySQLLockTables($server, $username, $password, $database, $testDetails) {
$this->testing($testDetails);
- $conn = @mysqli_connect($server, $username, $password);
+ $conn = $this->connect($server, $username, $password);
if (!$conn) {
$testDetails[2] = ts('Could not connect to the database server.');
$this->error($testDetails);
*/
public function requireMySQLAutoIncrementIncrementOne($server, $username, $password, $testDetails) {
$this->testing($testDetails);
- $conn = @mysqli_connect($server, $username, $password);
+ $conn = $this->connect($server, $username, $password);
if (!$conn) {
$testDetails[2] = ts('Could not connect to the database server.');
$this->error($testDetails);
*/
public function requireMySQLThreadStack($server, $username, $password, $database, $minValueKB, $testDetails) {
$this->testing($testDetails);
- $conn = @mysqli_connect($server, $username, $password);
+ $conn = $this->connect($server, $username, $password);
if (!$conn) {
$testDetails[2] = ts('Could not connect to the database server.');
$this->error($testDetails);
$onlyRequire = FALSE
) {
$this->testing($testDetails);
- $conn = @mysqli_connect($server, $username, $password);
+ $conn = $this->connect($server, $username, $password);
$okay = NULL;
if (@mysqli_select_db($conn, $database)) {
* @param $database
*/
public function createDatabaseIfNotExists($server, $username, $password, $database) {
- $conn = @mysqli_connect($server, $username, $password);
+ $conn = $this->connect($server, $username, $password);
if (@mysqli_select_db($conn, $database)) {
// skip if database already present