diff options
author | Thomas Müller <thomas.mueller@tmit.eu> | 2015-12-07 12:00:31 +0100 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2015-12-07 12:00:31 +0100 |
commit | d155c8e5fe500459884876046ccab5b2f28a4b43 (patch) | |
tree | b4b7b736e6fb9df23dddd09bd76383f5bcda0d5f /lib/private/setup | |
parent | e44b164f406b52530d81e755c9e1b959e0f1ef27 (diff) | |
download | nextcloud-server-d155c8e5fe500459884876046ccab5b2f28a4b43.tar.gz nextcloud-server-d155c8e5fe500459884876046ccab5b2f28a4b43.zip |
Add unix_socket support for mysql during initial installation - fixes #20210
Diffstat (limited to 'lib/private/setup')
-rw-r--r-- | lib/private/setup/mysql.php | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/lib/private/setup/mysql.php b/lib/private/setup/mysql.php index f2d2b15cd90..e8b88eb3489 100644 --- a/lib/private/setup/mysql.php +++ b/lib/private/setup/mysql.php @@ -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); } /** |