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.
This commit is contained in:
Adrian Greeve 2013-07-04 15:01:53 +08:00
parent f0d37f4ac5
commit b1d31f49dc

View File

@ -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 {