summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorJoas Schilling <nickvergessen@gmx.de>2015-01-23 11:13:47 +0100
committerJoas Schilling <nickvergessen@gmx.de>2015-01-23 14:52:21 +0100
commit039397bd3104d92f7957263520eab0ccfb54f869 (patch)
treebf87c547f087ba08cea035de5a881c35b2f4c9e3 /lib
parentc61e9f391273e5f7f4b7aa91ee4174d47402cae9 (diff)
downloadnextcloud-server-039397bd3104d92f7957263520eab0ccfb54f869.tar.gz
nextcloud-server-039397bd3104d92f7957263520eab0ccfb54f869.zip
Use setConfigs() instead of calling setConfig() multiple times
Diffstat (limited to 'lib')
-rw-r--r--lib/private/setup.php17
-rw-r--r--lib/private/setup/abstractdatabase.php8
-rw-r--r--lib/private/setup/mssql.php6
-rw-r--r--lib/private/setup/mysql.php6
-rw-r--r--lib/private/setup/oci.php52
-rw-r--r--lib/private/setup/postgresql.php19
6 files changed, 54 insertions, 54 deletions
diff --git a/lib/private/setup.php b/lib/private/setup.php
index b9ba8d906c2..e5f84d4c02a 100644
--- a/lib/private/setup.php
+++ b/lib/private/setup.php
@@ -176,18 +176,19 @@ class OC_Setup {
//generate a random salt that is used to salt the local user passwords
$salt = \OC::$server->getSecureRandom()->getLowStrengthGenerator()->generate(30);
- \OC::$server->getConfig()->setSystemValue('passwordsalt', $salt);
-
// generate a secret
$secret = \OC::$server->getSecureRandom()->getMediumStrengthGenerator()->generate(48);
- \OC::$server->getConfig()->setSystemValue('secret', $secret);
//write the config file
- \OC::$server->getConfig()->setSystemValue('trusted_domains', $trustedDomains);
- \OC::$server->getConfig()->setSystemValue('datadirectory', $dataDir);
- \OC::$server->getConfig()->setSystemValue('overwrite.cli.url', \OC_Request::serverProtocol() . '://' . \OC_Request::serverHost() . OC::$WEBROOT);
- \OC::$server->getConfig()->setSystemValue('dbtype', $dbType);
- \OC::$server->getConfig()->setSystemValue('version', implode('.', OC_Util::getVersion()));
+ \OC::$server->getConfig()->setSystemValues([
+ 'passwordsalt' => $salt,
+ 'secret' => $secret,
+ 'trusted_domains' => $trustedDomains,
+ 'datadirectory' => $dataDir,
+ 'overwrite.cli.url' => \OC_Request::serverProtocol() . '://' . \OC_Request::serverHost() . OC::$WEBROOT,
+ 'dbtype' => $dbType,
+ 'version' => implode('.', OC_Util::getVersion()),
+ ]);
try {
$dbSetup->initialize($options);
diff --git a/lib/private/setup/abstractdatabase.php b/lib/private/setup/abstractdatabase.php
index 84625a217ee..e421efe8028 100644
--- a/lib/private/setup/abstractdatabase.php
+++ b/lib/private/setup/abstractdatabase.php
@@ -41,9 +41,11 @@ abstract class AbstractDatabase {
$dbhost = !empty($config['dbhost']) ? $config['dbhost'] : 'localhost';
$dbtableprefix = isset($config['dbtableprefix']) ? $config['dbtableprefix'] : 'oc_';
- \OC_Config::setValue('dbname', $dbname);
- \OC_Config::setValue('dbhost', $dbhost);
- \OC_Config::setValue('dbtableprefix', $dbtableprefix);
+ \OC_Config::setValues([
+ 'dbname' => $dbname,
+ 'dbhost' => $dbhost,
+ 'dbtableprefix' => $dbtableprefix,
+ ]);
$this->dbuser = $dbuser;
$this->dbpassword = $dbpass;
diff --git a/lib/private/setup/mssql.php b/lib/private/setup/mssql.php
index 5143545b76f..f1699c36f96 100644
--- a/lib/private/setup/mssql.php
+++ b/lib/private/setup/mssql.php
@@ -21,8 +21,10 @@ class MSSQL extends AbstractDatabase {
$this->trans->t('You need to enter either an existing account or the administrator.'));
}
- \OC_Config::setValue('dbuser', $this->dbuser);
- \OC_Config::setValue('dbpassword', $this->dbpassword);
+ \OC_Config::setValues([
+ 'dbuser' => $this->dbuser,
+ 'dbpassword' => $this->dbpassword,
+ ]);
$this->createDBLogin($masterConnection);
diff --git a/lib/private/setup/mysql.php b/lib/private/setup/mysql.php
index 8f8d86d388c..97f75e2f676 100644
--- a/lib/private/setup/mysql.php
+++ b/lib/private/setup/mysql.php
@@ -51,8 +51,10 @@ class MySQL extends AbstractDatabase {
}
};
- \OC_Config::setValue('dbuser', $this->dbuser);
- \OC_Config::setValue('dbpassword', $this->dbpassword);
+ \OC_Config::setValues([
+ 'dbuser' => $this->dbuser,
+ 'dbpassword' => $this->dbpassword,
+ ]);
}
//create the database
diff --git a/lib/private/setup/oci.php b/lib/private/setup/oci.php
index b75b658bae2..d4f71f18ab4 100644
--- a/lib/private/setup/oci.php
+++ b/lib/private/setup/oci.php
@@ -16,8 +16,11 @@ class OCI extends AbstractDatabase {
}
// allow empty hostname for oracle
$this->dbhost = $config['dbhost'];
- \OC_Config::setValue('dbhost', $this->dbhost);
- \OC_Config::setValue('dbtablespace', $this->dbtablespace);
+
+ \OC_Config::setValues([
+ 'dbhost' => $this->dbhost,
+ 'dbtablespace' => $this->dbtablespace,
+ ]);
}
public function validate($config) {
@@ -72,37 +75,32 @@ class OCI extends AbstractDatabase {
$result = oci_execute($stmt);
if($result) {
$row = oci_fetch_row($stmt);
- }
- if($result and $row[0] > 0) {
- //use the admin login data for the new database user
- //add prefix to the oracle user name to prevent collisions
- $this->dbuser='oc_'.$username;
- //create a new password so we don't need to store the admin config in the config file
- $this->dbpassword=\OC_Util::generateRandomBytes(30);
+ if ($row[0] > 0) {
+ //use the admin login data for the new database user
- //oracle passwords are treated as identifiers:
- // must start with alphanumeric char
- // needs to be shortened to 30 bytes, as the two " needed to escape the identifier count towards the identifier length.
- $this->dbpassword=substr($this->dbpassword, 0, 30);
+ //add prefix to the oracle user name to prevent collisions
+ $this->dbuser='oc_'.$username;
+ //create a new password so we don't need to store the admin config in the config file
+ $this->dbpassword=\OC_Util::generateRandomBytes(30);
- $this->createDBUser($connection);
+ //oracle passwords are treated as identifiers:
+ // must start with alphanumeric char
+ // needs to be shortened to 30 bytes, as the two " needed to escape the identifier count towards the identifier length.
+ $this->dbpassword=substr($this->dbpassword, 0, 30);
- \OC_Config::setValue('dbuser', $this->dbuser);
- \OC_Config::setValue('dbname', $this->dbuser);
- \OC_Config::setValue('dbpassword', $this->dbpassword);
-
- //create the database not necessary, oracle implies user = schema
- //$this->createDatabase($this->dbname, $this->dbuser, $connection);
- } else {
+ $this->createDBUser($connection);
+ }
+ }
- \OC_Config::setValue('dbuser', $this->dbuser);
- \OC_Config::setValue('dbname', $this->dbname);
- \OC_Config::setValue('dbpassword', $this->dbpassword);
+ \OC_Config::setValues([
+ 'dbuser' => $this->dbuser,
+ 'dbname' => $this->dbname,
+ 'dbpassword' => $this->dbpassword,
+ ]);
- //create the database not necessary, oracle implies user = schema
- //$this->createDatabase($this->dbname, $this->dbuser, $connection);
- }
+ //create the database not necessary, oracle implies user = schema
+ //$this->createDatabase($this->dbname, $this->dbuser, $connection);
//FIXME check tablespace exists: select * from user_tablespaces
diff --git a/lib/private/setup/postgresql.php b/lib/private/setup/postgresql.php
index 3777d1620bc..5fb6b85fc89 100644
--- a/lib/private/setup/postgresql.php
+++ b/lib/private/setup/postgresql.php
@@ -43,20 +43,15 @@ class PostgreSQL extends AbstractDatabase {
$this->dbpassword=\OC_Util::generateRandomBytes(30);
$this->createDBUser($connection);
-
- \OC_Config::setValue('dbuser', $this->dbuser);
- \OC_Config::setValue('dbpassword', $this->dbpassword);
-
- //create the database
- $this->createDatabase($connection);
}
- else {
- \OC_Config::setValue('dbuser', $this->dbuser);
- \OC_Config::setValue('dbpassword', $this->dbpassword);
- //create the database
- $this->createDatabase($connection);
- }
+ \OC_Config::setValues([
+ 'dbuser' => $this->dbuser,
+ 'dbpassword' => $this->dbpassword,
+ ]);
+
+ //create the database
+ $this->createDatabase($connection);
// the connection to dbname=postgres is not needed anymore
pg_close($connection);