Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrank Karlitschek <frank@owncloud.org>2014-06-13 20:09:51 +0400
committerFrank Karlitschek <frank@owncloud.org>2014-06-13 20:09:51 +0400
commit87101e6638097d7c5397fd5ce926b0492be4fa6c (patch)
tree75a956cbb93feedc4e2fd8a723ef6694ad20f869 /lib/private/db.php
parentc09f5680c98d66d6e5a0fe793561194ecafed3ea (diff)
parent73062040e68212ac6e92d36211ca0bef91777589 (diff)
Merge pull request #9018 from owncloud/dbms-socket-support
Refactor OC_DB::connect() to properly support sockets.
Diffstat (limited to 'lib/private/db.php')
-rw-r--r--lib/private/db.php44
1 files changed, 19 insertions, 25 deletions
diff --git a/lib/private/db.php b/lib/private/db.php
index 82affe293ed..8fd2ef1c6f7 100644
--- a/lib/private/db.php
+++ b/lib/private/db.php
@@ -57,40 +57,34 @@ class OC_DB {
return true;
}
- // The global data we need
- $name = OC_Config::getValue( "dbname", "owncloud" );
- $host = OC_Config::getValue( "dbhost", "" );
- $user = OC_Config::getValue( "dbuser", "" );
- $pass = OC_Config::getValue( "dbpassword", "" );
- $type = OC_Config::getValue( "dbtype", "sqlite" );
- if(strpos($host, ':')) {
- list($host, $port)=explode(':', $host, 2);
- } else {
- $port=false;
- }
-
+ $type = OC_Config::getValue('dbtype', 'sqlite');
$factory = new \OC\DB\ConnectionFactory();
if (!$factory->isValidType($type)) {
return false;
}
+ $connectionParams = array(
+ 'user' => OC_Config::getValue('dbuser', ''),
+ 'password' => OC_Config::getValue('dbpassword', ''),
+ );
+ $name = OC_Config::getValue('dbname', 'owncloud');
+
if ($factory->normalizeType($type) === 'sqlite3') {
$datadir = OC_Config::getValue("datadirectory", OC::$SERVERROOT.'/data');
- $connectionParams = array(
- 'user' => $user,
- 'password' => $pass,
- 'path' => $datadir.'/'.$name.'.db',
- );
+ $connectionParams['path'] = $datadir.'/'.$name.'.db';
} else {
- $connectionParams = array(
- 'user' => $user,
- 'password' => $pass,
- 'host' => $host,
- 'dbname' => $name,
- );
- if (!empty($port)) {
- $connectionParams['port'] = $port;
+ $host = OC_Config::getValue('dbhost', '');
+ if (strpos($host, ':')) {
+ // Host variable may carry a port or socket.
+ list($host, $portOrSocket) = explode(':', $host, 2);
+ if (ctype_digit($portOrSocket)) {
+ $connectionParams['host'] = $host;
+ $connectionParams['port'] = $portOrSocket;
+ } else {
+ $connectionParams['unix_socket'] = $portOrSocket;
+ }
}
+ $connectionParams['dbname'] = $name;
}
$connectionParams['tablePrefix'] = OC_Config::getValue('dbtableprefix', 'oc_');