summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2016-07-26 11:44:15 +0200
committerRobin Appelman <robin@icewind.nl>2016-07-26 11:44:15 +0200
commit0e83f5dbd78600ea5595862c5a215b734166c888 (patch)
tree1c80c2eab558683c0e3faf1218d84eb754dc0513 /lib
parentcc5ddcf537d03c3f2f4cdc6817e02e098f8e8edb (diff)
downloadnextcloud-server-0e83f5dbd78600ea5595862c5a215b734166c888.tar.gz
nextcloud-server-0e83f5dbd78600ea5595862c5a215b734166c888.zip
revert to old setup connection logic
Diffstat (limited to 'lib')
-rw-r--r--lib/private/Setup/AbstractDatabase.php36
1 files changed, 26 insertions, 10 deletions
diff --git a/lib/private/Setup/AbstractDatabase.php b/lib/private/Setup/AbstractDatabase.php
index 65f6a8c5b7c..310f74d4c0c 100644
--- a/lib/private/Setup/AbstractDatabase.php
+++ b/lib/private/Setup/AbstractDatabase.php
@@ -108,18 +108,34 @@ abstract class AbstractDatabase {
* @return \OC\DB\Connection
*/
protected function connect(array $configOverwrite = []) {
- $systemConfig = $this->config->getSystemConfig();
- $cf = new ConnectionFactory();
- $connectionParams = $cf->createConnectionParams($systemConfig);
- // we don't save username/password to the config immediately so this might not be set
- if (!$connectionParams['user']) {
- $connectionParams['user'] = $this->dbUser;
- }
- if (!$connectionParams['password']) {
- $connectionParams['password'] = $this->dbPassword;
+ $connectionParams = array(
+ 'host' => $this->dbHost,
+ 'user' => $this->dbUser,
+ 'password' => $this->dbPassword,
+ 'tablePrefix' => $this->tablePrefix,
+ );
+
+ // adding port support through installer
+ 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);
- return $cf->getConnection($systemConfig->getValue('dbtype', 'sqlite'), $connectionParams);
+ $cf = new ConnectionFactory();
+ return $cf->getConnection($this->config->getSystemValue('dbtype', 'sqlite'), $connectionParams);
}
/**