Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'w06_MDL-26290_20_mysqlport' of git://github.com/skodak/…

…moodle
  • Loading branch information...
commit 9beb04e1d51a3c05c5cf7060a1fe49c3ded4e34a 2 parents c055ceb + 8c4b142
@stronk7 stronk7 authored
Showing with 12 additions and 3 deletions.
  1. +12 −3 lib/dml/mysqli_native_moodle_database.php
View
15 lib/dml/mysqli_native_moodle_database.php
@@ -57,10 +57,14 @@ public function create_database($dbhost, $dbuser, $dbpass, $dbname, array $dbopt
}
if (empty($this->dboptions['dbport'])) {
- $dbport = ini_get('mysqli.default_port');
+ $dbport = (int)ini_get('mysqli.default_port');
} else {
$dbport = (int)$this->dboptions['dbport'];
}
+ // verify ini.get does not return nonsense
+ if (empty($dbport)) {
+ $dbport = 3306;
+ }
ob_start();
$conn = new mysqli($dbhost, $dbuser, $dbpass, '', $dbport); /// Connect without db
$dberr = ob_get_contents();
@@ -267,16 +271,21 @@ public function connect($dbhost, $dbuser, $dbpass, $dbname, $prefix, array $dbop
// dbsocket is used ONLY if host is NULL or 'localhost',
// you can not disable it because it is always tried if dbhost is 'localhost'
- if (!empty($this->dboptions['dbsocket']) and strpos($this->dboptions['dbsocket'], '/') !== false) {
+ if (!empty($this->dboptions['dbsocket'])
+ and (strpos($this->dboptions['dbsocket'], '/') !== false or strpos($this->dboptions['dbsocket'], '\\') !== false)) {
$dbsocket = $this->dboptions['dbsocket'];
} else {
$dbsocket = ini_get('mysqli.default_socket');
}
if (empty($this->dboptions['dbport'])) {
- $dbport = ini_get('mysqli.default_port');
+ $dbport = (int)ini_get('mysqli.default_port');
} else {
$dbport = (int)$this->dboptions['dbport'];
}
+ // verify ini.get does not return nonsense
+ if (empty($dbport)) {
+ $dbport = 3306;
+ }
ob_start();
$this->mysqli = new mysqli($dbhost, $dbuser, $dbpass, $dbname, $dbport, $dbsocket);
$dberr = ob_get_contents();
Please sign in to comment.
Something went wrong with that request. Please try again.