Merge pull request #641 from nextcloud/backport-566-stable10
[stable10] revert to old setup connection logic
This commit is contained in:
commit
eee791ad56
|
@ -108,18 +108,34 @@ abstract class AbstractDatabase {
|
||||||
* @return \OC\DB\Connection
|
* @return \OC\DB\Connection
|
||||||
*/
|
*/
|
||||||
protected function connect(array $configOverwrite = []) {
|
protected function connect(array $configOverwrite = []) {
|
||||||
$systemConfig = $this->config->getSystemConfig();
|
$connectionParams = array(
|
||||||
$cf = new ConnectionFactory();
|
'host' => $this->dbHost,
|
||||||
$connectionParams = $cf->createConnectionParams($systemConfig);
|
'user' => $this->dbUser,
|
||||||
// we don't save username/password to the config immediately so this might not be set
|
'password' => $this->dbPassword,
|
||||||
if (!$connectionParams['user']) {
|
'tablePrefix' => $this->tablePrefix,
|
||||||
$connectionParams['user'] = $this->dbUser;
|
);
|
||||||
}
|
|
||||||
if (!$connectionParams['password']) {
|
// adding port support through installer
|
||||||
$connectionParams['password'] = $this->dbPassword;
|
if (!empty($this->dbPort)) {
|
||||||
|
if (ctype_digit($this->dbPort)) {
|
||||||
|
$connectionParams['port'] = $this->dbPort;
|
||||||
|
} else {
|
||||||
|
$connectionParams['unix_socket'] = $this->dbPort;
|
||||||
|
}
|
||||||
|
} else 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
$connectionParams = array_merge($connectionParams, $configOverwrite);
|
$connectionParams = array_merge($connectionParams, $configOverwrite);
|
||||||
return $cf->getConnection($systemConfig->getValue('dbtype', 'sqlite'), $connectionParams);
|
$cf = new ConnectionFactory();
|
||||||
|
return $cf->getConnection($this->config->getSystemValue('dbtype', 'sqlite'), $connectionParams);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue