]> source.dussan.org Git - nextcloud-server.git/commitdiff
Move check for : to where it belongs, getting rid of $socket = false;
authorAndreas Fischer <bantu@owncloud.com>
Thu, 12 Jun 2014 17:55:26 +0000 (19:55 +0200)
committerAndreas Fischer <bantu@owncloud.com>
Thu, 12 Jun 2014 17:56:51 +0000 (19:56 +0200)
lib/private/db.php

index 6f0596f328eeb567eda0e0e9b7c84fb28564b57c..df558dfce15515c236cdff0431b3032eceeb9b2a 100644 (file)
@@ -63,11 +63,6 @@ class OC_DB {
                $user = OC_Config::getValue( "dbuser", "" );
                $pass = OC_Config::getValue( "dbpassword", "" );
                $type = OC_Config::getValue( "dbtype", "sqlite" );
-               if(strpos($host, ':')) {
-                       list($host, $socket)=explode(':', $host, 2);
-               } else {
-                       $socket=FALSE;
-               }
 
                $factory = new \OC\DB\ConnectionFactory();
                if (!$factory->isValidType($type)) {
@@ -83,15 +78,17 @@ class OC_DB {
                        $datadir = OC_Config::getValue("datadirectory", OC::$SERVERROOT.'/data');
                        $connectionParams['path'] = $datadir.'/'.$name.'.db';
                } else {
-                       $connectionParams['host'] = $host;
-                       $connectionParams['dbname'] = $name;
-                       if ($socket) {
+                       if (strpos($host, ':')) {
+                               // Host variable may carry a port or socket.
+                               list($host, $socket) = explode(':', $host, 2);
                                if (ctype_digit($socket) && $socket <= 65535) {
                                        $connectionParams['port'] = $socket;
                                } else {
                                        $connectionParams['unix_socket'] = $socket;
                                }
                        }
+                       $connectionParams['host'] = $host;
+                       $connectionParams['dbname'] = $name;
                }
 
                $connectionParams['tablePrefix'] = OC_Config::getValue('dbtableprefix', 'oc_');