]> source.dussan.org Git - nextcloud-server.git/commitdiff
revert to old setup connection logic 641/head
authorRobin Appelman <robin@icewind.nl>
Tue, 26 Jul 2016 09:44:15 +0000 (11:44 +0200)
committerArthur Schiwon <blizzz@arthur-schiwon.de>
Thu, 28 Jul 2016 22:41:12 +0000 (00:41 +0200)
lib/private/Setup/AbstractDatabase.php

index 65f6a8c5b7c0d0a1de3a345c2dee347b88d743d2..310f74d4c0c1671218cfb5e18dab7632e890cf12 100644 (file)
@@ -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);
        }
 
        /**