]> source.dussan.org Git - nextcloud-server.git/commitdiff
Work with MySQL Sockets
authorjosh4trunks <joshruehlig@gmail.com>
Thu, 5 Jun 2014 05:50:23 +0000 (22:50 -0700)
committerjosh4trunks <joshruehlig@gmail.com>
Thu, 5 Jun 2014 05:50:23 +0000 (22:50 -0700)
This passes anything that is not a valid port (0<int<65535) as a unix socket.
I tested this with unix sockets; this needs to be tested with a non-standard mysql port as well but I don't foresee any issues.

To use a unix socket, even one different than PHP's mysql.default_socket..
* Database Host = localhost:/path/to/socket

lib/private/db.php

index 422f783c745633ac3941f5ff1fd79ba889b54ea2..16030a20f89436fca99c2d20c12e6e4838bbfd83 100644 (file)
@@ -65,6 +65,9 @@ class OC_DB {
                $type = OC_Config::getValue( "dbtype", "sqlite" );
                if(strpos($host, ':')) {
                        list($host, $port)=explode(':', $host, 2);
+                       if(!is_int($port)||$port<1||$port>65535) {
+                               $socket=true;
+                       }
                } else {
                        $port=false;
                }
@@ -89,7 +92,11 @@ class OC_DB {
                                'dbname' => $name,
                        );
                        if (!empty($port)) {
-                               $connectionParams['port'] = $port;
+                               if ($socket) {
+                                       $connectionParams['unix_socket'] = $port;
+                               } else {
+                                       $connectionParams['port'] = $port;
+                               }
                        }
                }