Permalink
Browse files

MDL-26307 fix dbport and dbsocket support when creating mysql database

  • Loading branch information...
1 parent d911c72 commit 9e9543e54b0ed6c9a58e7435ef9747c943ee0843 @skodak skodak committed Feb 12, 2011
Showing with 9 additions and 3 deletions.
  1. +9 −3 lib/dml/mysqli_native_moodle_database.php
@@ -56,17 +56,23 @@ public function create_database($dbhost, $dbuser, $dbpass, $dbname, array $dbopt
throw new dml_exception('dbdriverproblem', $driverstatus);
}
- if (empty($this->dboptions['dbport'])) {
+ if (!empty($dboptions['dbsocket'])
+ and (strpos($dboptions['dbsocket'], '/') !== false or strpos($dboptions['dbsocket'], '\\') !== false)) {
+ $dbsocket = $dboptions['dbsocket'];
+ } else {
+ $dbsocket = ini_get('mysqli.default_socket');
+ }
+ if (empty($dboptions['dbport'])) {
$dbport = (int)ini_get('mysqli.default_port');
} else {
- $dbport = (int)$this->dboptions['dbport'];
+ $dbport = (int)$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
+ $conn = new mysqli($dbhost, $dbuser, $dbpass, '', $dbport, $dbsocket); /// Connect without db
$dberr = ob_get_contents();
ob_end_clean();
$errorno = @$conn->connect_errno;

0 comments on commit 9e9543e

Please sign in to comment.