diff options
author | Morris Jobke <hey@morrisjobke.de> | 2017-03-17 16:37:48 -0600 |
---|---|---|
committer | Morris Jobke <hey@morrisjobke.de> | 2017-03-19 15:53:49 -0600 |
commit | edd55b0ea9c13273695bf95d913f4dfc03e08c95 (patch) | |
tree | 71bcb99c0d2b5fd16d97eadcc947e11488c23817 /lib/private/Setup | |
parent | c02527e41462133444881817b741f91ebf563b3b (diff) | |
download | nextcloud-server-edd55b0ea9c13273695bf95d913f4dfc03e08c95.tar.gz nextcloud-server-edd55b0ea9c13273695bf95d913f4dfc03e08c95.zip |
Use SystemConfig instead of AllConfig for DB stuff
* preparation for followup PRs to clean up the DB bootstrapping
Signed-off-by: Morris Jobke <hey@morrisjobke.de>
Diffstat (limited to 'lib/private/Setup')
-rw-r--r-- | lib/private/Setup/AbstractDatabase.php | 10 | ||||
-rw-r--r-- | lib/private/Setup/MySQL.php | 6 | ||||
-rw-r--r-- | lib/private/Setup/OCI.php | 8 | ||||
-rw-r--r-- | lib/private/Setup/PostgreSQL.php | 9 | ||||
-rw-r--r-- | lib/private/Setup/Sqlite.php | 2 |
5 files changed, 17 insertions, 18 deletions
diff --git a/lib/private/Setup/AbstractDatabase.php b/lib/private/Setup/AbstractDatabase.php index dbf46888ffe..c554e569a63 100644 --- a/lib/private/Setup/AbstractDatabase.php +++ b/lib/private/Setup/AbstractDatabase.php @@ -28,7 +28,7 @@ namespace OC\Setup; use OC\AllConfig; use OC\DB\ConnectionFactory; -use OCP\IConfig; +use OC\SystemConfig; use OCP\IL10N; use OCP\ILogger; use OCP\Security\ISecureRandom; @@ -51,14 +51,14 @@ abstract class AbstractDatabase { protected $dbPort; /** @var string */ protected $tablePrefix; - /** @var AllConfig */ + /** @var SystemConfig */ protected $config; /** @var ILogger */ protected $logger; /** @var ISecureRandom */ protected $random; - public function __construct(IL10N $trans, $dbDefinitionFile, IConfig $config, ILogger $logger, ISecureRandom $random) { + public function __construct(IL10N $trans, $dbDefinitionFile, SystemConfig $config, ILogger $logger, ISecureRandom $random) { $this->trans = $trans; $this->dbDefinitionFile = $dbDefinitionFile; $this->config = $config; @@ -89,7 +89,7 @@ abstract class AbstractDatabase { $dbPort = !empty($config['dbport']) ? $config['dbport'] : ''; $dbTablePrefix = isset($config['dbtableprefix']) ? $config['dbtableprefix'] : 'oc_'; - $this->config->setSystemValues([ + $this->config->setValues([ 'dbname' => $dbName, 'dbhost' => $dbHost, 'dbport' => $dbPort, @@ -137,7 +137,7 @@ abstract class AbstractDatabase { $connectionParams = array_merge($connectionParams, $configOverwrite); $cf = new ConnectionFactory($this->config); - return $cf->getConnection($this->config->getSystemValue('dbtype', 'sqlite'), $connectionParams); + return $cf->getConnection($this->config->getValue('dbtype', 'sqlite'), $connectionParams); } /** diff --git a/lib/private/Setup/MySQL.php b/lib/private/Setup/MySQL.php index f4ba0e7326a..9998ca401d9 100644 --- a/lib/private/Setup/MySQL.php +++ b/lib/private/Setup/MySQL.php @@ -58,7 +58,7 @@ class MySQL extends AbstractDatabase { $name = $this->dbName; $user = $this->dbUser; //we can't use OC_DB functions here because we need to connect as the administrative user. - $characterSet = \OC::$server->getSystemConfig()->getValue('mysql.utf8mb4', false) ? 'utf8mb4' : 'utf8'; + $characterSet = $this->config->getValue('mysql.utf8mb4', false) ? 'utf8mb4' : 'utf8'; $query = "CREATE DATABASE IF NOT EXISTS `$name` CHARACTER SET $characterSet COLLATE ${characterSet}_bin;"; $connection->executeUpdate($query); } catch (\Exception $ex) { @@ -112,7 +112,7 @@ class MySQL extends AbstractDatabase { private function createSpecificUser($username, $connection) { try { //user already specified in config - $oldUser = $this->config->getSystemValue('dbuser', false); + $oldUser = $this->config->getValue('dbuser', false); //we don't have a dbuser specified in config if ($this->dbUser !== $oldUser) { @@ -157,7 +157,7 @@ class MySQL extends AbstractDatabase { ]); } - $this->config->setSystemValues([ + $this->config->setValues([ 'dbuser' => $this->dbUser, 'dbpassword' => $this->dbPassword, ]); diff --git a/lib/private/Setup/OCI.php b/lib/private/Setup/OCI.php index 2a20cfa8360..0538b3da98b 100644 --- a/lib/private/Setup/OCI.php +++ b/lib/private/Setup/OCI.php @@ -45,7 +45,7 @@ class OCI extends AbstractDatabase { // allow empty hostname for oracle $this->dbHost = $config['dbhost']; - $this->config->setSystemValues([ + $this->config->setValues([ 'dbhost' => $this->dbHost, 'dbtablespace' => $this->dbtablespace, ]); @@ -124,7 +124,7 @@ class OCI extends AbstractDatabase { } } - $this->config->setSystemValues([ + $this->config->setValues([ 'dbuser' => $this->dbUser, 'dbname' => $this->dbName, 'dbpassword' => $this->dbPassword, @@ -139,9 +139,9 @@ class OCI extends AbstractDatabase { oci_close($connection); // connect to the oracle database (schema=$this->dbuser) an check if the schema needs to be filled - $this->dbUser = $this->config->getSystemValue('dbuser'); + $this->dbUser = $this->config->getValue('dbuser'); //$this->dbname = \OC_Config::getValue('dbname'); - $this->dbPassword = $this->config->getSystemValue('dbpassword'); + $this->dbPassword = $this->config->getValue('dbpassword'); $e_host = addslashes($this->dbHost); $e_dbname = addslashes($this->dbName); diff --git a/lib/private/Setup/PostgreSQL.php b/lib/private/Setup/PostgreSQL.php index c01e5bc0332..be3ac007493 100644 --- a/lib/private/Setup/PostgreSQL.php +++ b/lib/private/Setup/PostgreSQL.php @@ -35,7 +35,6 @@ class PostgreSQL extends AbstractDatabase { public $dbprettyname = 'PostgreSQL'; public function setupDatabase($username) { - $systemConfig = $this->config->getSystemConfig(); try { $connection = $this->connect([ 'dbname' => 'postgres' @@ -67,7 +66,7 @@ class PostgreSQL extends AbstractDatabase { $this->createDBUser($connection); } - $systemConfig->setValues([ + $this->config->setValues([ 'dbuser' => $this->dbUser, 'dbpassword' => $this->dbPassword, ]); @@ -84,15 +83,15 @@ class PostgreSQL extends AbstractDatabase { $this->logger->logException($e); $this->logger->warning('Error trying to connect as "postgres", assuming database is setup and tables need to be created'); $tablesSetup = false; - $systemConfig->setValues([ + $this->config->setValues([ 'dbuser' => $this->dbUser, 'dbpassword' => $this->dbPassword, ]); } // connect to the ownCloud database (dbname=$this->dbname) and check if it needs to be filled - $this->dbUser = $systemConfig->getValue('dbuser'); - $this->dbPassword = $systemConfig->getValue('dbpassword'); + $this->dbUser = $this->config->getValue('dbuser'); + $this->dbPassword = $this->config->getValue('dbpassword'); $connection = $this->connect(); try { $connection->connect(); diff --git a/lib/private/Setup/Sqlite.php b/lib/private/Setup/Sqlite.php index 4d860103b60..87c0b82682f 100644 --- a/lib/private/Setup/Sqlite.php +++ b/lib/private/Setup/Sqlite.php @@ -33,7 +33,7 @@ class Sqlite extends AbstractDatabase { } public function setupDatabase($username) { - $datadir = \OC::$server->getSystemConfig()->getValue('datadirectory', \OC::$SERVERROOT . '/data'); + $datadir = $this->config->getValue('datadirectory', \OC::$SERVERROOT . '/data'); //delete the old sqlite database first, might cause infinte loops otherwise if(file_exists("$datadir/owncloud.db")) { |