Permalink
Browse files

MDL-25910 add support for custom mysql socket location

  • Loading branch information...
1 parent 5a7f931 commit 79ac5a8cf2c6fe3214aaac4628dd27da27f1ff06 @skodak skodak committed Jan 14, 2011
Showing with 8 additions and 2 deletions.
  1. +8 −2 lib/dml/mysqli_native_moodle_database.php
@@ -264,15 +264,21 @@ public function connect($dbhost, $dbuser, $dbpass, $dbname, $prefix, array $dbop
}
$this->store_settings($dbhost, $dbuser, $dbpass, $dbname, $prefix, $dboptions);
- unset($this->dboptions['dbsocket']);
+ // 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) {
+ $dbsocket = $this->dboptions['dbsocket'];
+ } else {
+ $dbsocket = ini_get('mysqli.default_socket');
+ }
if (empty($this->dboptions['dbport'])) {
$dbport = ini_get('mysqli.default_port');
} else {
$dbport = (int)$this->dboptions['dbport'];
}
ob_start();
- $this->mysqli = new mysqli($dbhost, $dbuser, $dbpass, $dbname, $dbport);
+ $this->mysqli = new mysqli($dbhost, $dbuser, $dbpass, $dbname, $dbport, $dbsocket);
$dberr = ob_get_contents();
ob_end_clean();
$errorno = @$this->mysqli->connect_errno;

0 comments on commit 79ac5a8

Please sign in to comment.