From b1d31f49dc073e4ae4cf1a7a12d7f6d55a6fdac1 Mon Sep 17 00:00:00 2001 From: Adrian Greeve Date: Thu, 4 Jul 2013 15:01:53 +0800 Subject: [PATCH] MDL-40490 - database: Fixed a check on database port options. The addition of a port for the database means that an array would be set regardless of whether it had any information or not. The isset() function sees an array as being set and follows through with the rest of the if statement concatenating a colon to the end of the database host name and throwing a connection problem if no port number is supplied. The if statement has now been changed to if not empty. The empty function does see zero as an empty value, but a port shouldn't have a value of zero anyway. --- lib/dml/mssql_native_moodle_database.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/dml/mssql_native_moodle_database.php b/lib/dml/mssql_native_moodle_database.php index e1ea067c5e9..14716b66e4e 100644 --- a/lib/dml/mssql_native_moodle_database.php +++ b/lib/dml/mssql_native_moodle_database.php @@ -140,7 +140,8 @@ class mssql_native_moodle_database extends moodle_database { $this->store_settings($dbhost, $dbuser, $dbpass, $dbname, $prefix, $dboptions); $dbhost = $this->dbhost; - if (isset($dboptions['dbport'])) { + // Zero shouldn't be used as a port number so doing a check with empty() should be fine. + if (!empty($dboptions['dbport'])) { if (stristr(PHP_OS, 'win') && !stristr(PHP_OS, 'darwin')) { $dbhost .= ','.$dboptions['dbport']; } else {