Add unix_socket support for mysql during initial installation - fixes #20210

This commit is contained in:
Thomas Müller 2015-12-07 12:00:31 +01:00
parent e44b164f40
commit d155c8e5fe

View file

@ -89,15 +89,28 @@ class MySQL extends AbstractDatabase {
* @throws \OC\DatabaseSetupException
*/
private function connect() {
$type = 'mysql';
$connectionParams = array(
'host' => $this->dbHost,
'user' => $this->dbUser,
'password' => $this->dbPassword,
'tablePrefix' => $this->tablePrefix,
'host' => $this->dbHost,
'user' => $this->dbUser,
'password' => $this->dbPassword,
'tablePrefix' => $this->tablePrefix,
);
// adding port support
if (strpos($this->dbHost, ':')) {
// Host variable may carry a port or socket.
list($host, $portOrSocket) = explode(':', $this->dbHost, 2);
if (ctype_digit($portOrSocket)) {
$connectionParams['port'] = $portOrSocket;
} else {
$connectionParams['unix_socket'] = $portOrSocket;
}
$connectionParams['host'] = $host;
}
$cf = new ConnectionFactory();
return $cf->getConnection($type, $connectionParams);
return $cf->getConnection('mysql', $connectionParams);
}
/**