From 77f9f23b0f47fec562ac7cfc0aba285ded581de0 Mon Sep 17 00:00:00 2001 From: Petr Skoda Date: Sun, 6 Feb 2011 21:15:40 +0100 Subject: [PATCH 1/2] MDL-26290 make sure ini_get('mysqli.default_port') returns number --- lib/dml/mysqli_native_moodle_database.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/dml/mysqli_native_moodle_database.php b/lib/dml/mysqli_native_moodle_database.php index b22ca0943d4..450e57aa2b0 100644 --- a/lib/dml/mysqli_native_moodle_database.php +++ b/lib/dml/mysqli_native_moodle_database.php @@ -57,10 +57,14 @@ class mysqli_native_moodle_database extends moodle_database { } 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(); @@ -273,10 +277,14 @@ class mysqli_native_moodle_database extends moodle_database { $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(); From 8c4b142cb20a17a3d420379e5067bfc2a48ab8ec Mon Sep 17 00:00:00 2001 From: Petr Skoda Date: Sun, 6 Feb 2011 22:11:28 +0100 Subject: [PATCH 2/2] MDL-26290 add experimental windows mysqli named pipe support --- lib/dml/mysqli_native_moodle_database.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/dml/mysqli_native_moodle_database.php b/lib/dml/mysqli_native_moodle_database.php index 450e57aa2b0..c9064ad15ea 100644 --- a/lib/dml/mysqli_native_moodle_database.php +++ b/lib/dml/mysqli_native_moodle_database.php @@ -271,7 +271,8 @@ class mysqli_native_moodle_database extends moodle_database { // 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');