diff options
Diffstat (limited to 'lib/private')
-rw-r--r-- | lib/private/Console/Application.php | 2 | ||||
-rw-r--r-- | lib/private/DB/ConnectionFactory.php | 36 | ||||
-rw-r--r-- | lib/private/Server.php | 4 | ||||
-rw-r--r-- | lib/private/Setup.php | 18 | ||||
-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 | ||||
-rw-r--r-- | lib/private/legacy/util.php | 22 |
10 files changed, 62 insertions, 55 deletions
diff --git a/lib/private/Console/Application.php b/lib/private/Console/Application.php index f7806ba01a7..7d2f03d593e 100644 --- a/lib/private/Console/Application.php +++ b/lib/private/Console/Application.php @@ -134,7 +134,7 @@ class Application { } if ($input->getFirstArgument() !== 'check') { - $errors = \OC_Util::checkServer(\OC::$server->getConfig()); + $errors = \OC_Util::checkServer(\OC::$server->getSystemConfig()); if (!empty($errors)) { foreach ($errors as $error) { $output->writeln((string)$error['error']); diff --git a/lib/private/DB/ConnectionFactory.php b/lib/private/DB/ConnectionFactory.php index 1b53cd4b7c0..d8f1fb2480d 100644 --- a/lib/private/DB/ConnectionFactory.php +++ b/lib/private/DB/ConnectionFactory.php @@ -30,7 +30,7 @@ use Doctrine\DBAL\Configuration; use Doctrine\DBAL\DriverManager; use Doctrine\DBAL\Event\Listeners\OracleSessionInit; use Doctrine\DBAL\Event\Listeners\SQLSessionInit; -use OCP\IConfig; +use OC\SystemConfig; /** * Takes care of creating and configuring Doctrine connections. @@ -67,8 +67,17 @@ class ConnectionFactory { ], ]; - public function __construct(IConfig $config) { - if($config->getSystemValue('mysql.utf8mb4', false)) { + /** @var SystemConfig */ + private $config; + + /** + * ConnectionFactory constructor. + * + * @param SystemConfig $systemConfig + */ + public function __construct(SystemConfig $systemConfig) { + $this->config = $systemConfig; + if($this->config->getValue('mysql.utf8mb4', false)) { $this->defaultConnectionParams['mysql']['charset'] = 'utf8mb4'; } } @@ -154,23 +163,22 @@ class ConnectionFactory { /** * Create the connection parameters for the config * - * @param \OC\SystemConfig $config * @return array */ - public function createConnectionParams($config) { - $type = $config->getValue('dbtype', 'sqlite'); + public function createConnectionParams() { + $type = $this->config->getValue('dbtype', 'sqlite'); $connectionParams = [ - 'user' => $config->getValue('dbuser', ''), - 'password' => $config->getValue('dbpassword', ''), + 'user' => $this->config->getValue('dbuser', ''), + 'password' => $this->config->getValue('dbpassword', ''), ]; - $name = $config->getValue('dbname', 'owncloud'); + $name = $this->config->getValue('dbname', 'owncloud'); if ($this->normalizeType($type) === 'sqlite3') { - $dataDir = $config->getValue("datadirectory", \OC::$SERVERROOT . '/data'); + $dataDir = $this->config->getValue("datadirectory", \OC::$SERVERROOT . '/data'); $connectionParams['path'] = $dataDir . '/' . $name . '.db'; } else { - $host = $config->getValue('dbhost', ''); + $host = $this->config->getValue('dbhost', ''); if (strpos($host, ':')) { // Host variable may carry a port or socket. list($host, $portOrSocket) = explode(':', $host, 2); @@ -184,11 +192,11 @@ class ConnectionFactory { $connectionParams['dbname'] = $name; } - $connectionParams['tablePrefix'] = $config->getValue('dbtableprefix', 'oc_'); - $connectionParams['sqlite.journal_mode'] = $config->getValue('sqlite.journal_mode', 'WAL'); + $connectionParams['tablePrefix'] = $this->config->getValue('dbtableprefix', 'oc_'); + $connectionParams['sqlite.journal_mode'] = $this->config->getValue('sqlite.journal_mode', 'WAL'); //additional driver options, eg. for mysql ssl - $driverOptions = $config->getValue('dbdriveroptions', null); + $driverOptions = $this->config->getValue('dbdriveroptions', null); if ($driverOptions) { $connectionParams['driverOptions'] = $driverOptions; } diff --git a/lib/private/Server.php b/lib/private/Server.php index 969b65f9553..24cd8b38684 100644 --- a/lib/private/Server.php +++ b/lib/private/Server.php @@ -479,12 +479,12 @@ class Server extends ServerContainer implements IServerContainer { }); $this->registerService('DatabaseConnection', function (Server $c) { $systemConfig = $c->getSystemConfig(); - $factory = new \OC\DB\ConnectionFactory($c->getConfig()); + $factory = new \OC\DB\ConnectionFactory($systemConfig); $type = $systemConfig->getValue('dbtype', 'sqlite'); if (!$factory->isValidType($type)) { throw new \OC\DatabaseException('Invalid database type'); } - $connectionParams = $factory->createConnectionParams($systemConfig); + $connectionParams = $factory->createConnectionParams(); $connection = $factory->getConnection($type, $connectionParams); $connection->getConfiguration()->setSQLLogger($c->getQueryLogger()); return $connection; diff --git a/lib/private/Setup.php b/lib/private/Setup.php index 82338b40ce5..7a2957b5fb3 100644 --- a/lib/private/Setup.php +++ b/lib/private/Setup.php @@ -47,7 +47,7 @@ use OCP\ILogger; use OCP\Security\ISecureRandom; class Setup { - /** @var \OCP\IConfig */ + /** @var SystemConfig */ protected $config; /** @var IniGetWrapper */ protected $iniWrapper; @@ -61,11 +61,11 @@ class Setup { protected $random; /** - * @param IConfig $config + * @param SystemConfig $config * @param IniGetWrapper $iniWrapper * @param \OC_Defaults $defaults */ - function __construct(IConfig $config, + function __construct(SystemConfig $config, IniGetWrapper $iniWrapper, IL10N $l10n, \OC_Defaults $defaults, @@ -148,7 +148,7 @@ class Setup { if ($allowAllDatabases) { $configuredDatabases = array_keys($availableDatabases); } else { - $configuredDatabases = $this->config->getSystemValue('supportedDatabases', + $configuredDatabases = $this->config->getValue('supportedDatabases', array('sqlite', 'mysql', 'pgsql')); } if(!is_array($configuredDatabases)) { @@ -187,7 +187,7 @@ class Setup { public function getSystemInfo($allowAllDatabases = false) { $databases = $this->getSupportedDatabases($allowAllDatabases); - $dataDir = $this->config->getSystemValue('datadirectory', \OC::$SERVERROOT.'/data'); + $dataDir = $this->config->getValue('datadirectory', \OC::$SERVERROOT.'/data'); $errors = array(); @@ -315,7 +315,7 @@ class Setup { $secret = $this->random->generate(48); //write the config file - $this->config->setSystemValues([ + $this->config->setValues([ 'passwordsalt' => $salt, 'secret' => $secret, 'trusted_domains' => $trustedDomains, @@ -407,11 +407,11 @@ class Setup { * @return bool True when success, False otherwise */ public static function updateHtaccess() { - $config = \OC::$server->getConfig(); + $config = \OC::$server->getSystemConfig(); // For CLI read the value from overwrite.cli.url if(\OC::$CLI) { - $webRoot = $config->getSystemValue('overwrite.cli.url', ''); + $webRoot = $config->getValue('overwrite.cli.url', ''); if($webRoot === '') { return false; } @@ -436,7 +436,7 @@ class Setup { $content.= "\nErrorDocument 404 ".$webRoot."/core/templates/404.php"; // Add rewrite rules if the RewriteBase is configured - $rewriteBase = $config->getSystemValue('htaccess.RewriteBase', ''); + $rewriteBase = $config->getValue('htaccess.RewriteBase', ''); if($rewriteBase !== '') { $content .= "\n<IfModule mod_rewrite.c>"; $content .= "\n Options -MultiViews"; 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")) { diff --git a/lib/private/legacy/util.php b/lib/private/legacy/util.php index 82fb07eb95a..7f351c5b00e 100644 --- a/lib/private/legacy/util.php +++ b/lib/private/legacy/util.php @@ -631,15 +631,15 @@ class OC_Util { /** * check if the current server configuration is suitable for ownCloud * - * @param \OCP\IConfig $config + * @param \OC\SystemConfig $config * @return array arrays with error messages and hints */ - public static function checkServer(\OCP\IConfig $config) { + public static function checkServer(\OC\SystemConfig $config) { $l = \OC::$server->getL10N('lib'); $errors = array(); - $CONFIG_DATADIRECTORY = $config->getSystemValue('datadirectory', OC::$SERVERROOT . '/data'); + $CONFIG_DATADIRECTORY = $config->getValue('datadirectory', OC::$SERVERROOT . '/data'); - if (!self::needUpgrade($config) && $config->getSystemValue('installed', false)) { + if (!self::needUpgrade($config) && $config->getValue('installed', false)) { // this check needs to be done every time $errors = self::checkDataDirectoryValidity($CONFIG_DATADIRECTORY); } @@ -677,7 +677,7 @@ class OC_Util { } // Check if there is a writable install folder. - if ($config->getSystemValue('appstoreenabled', true)) { + if ($config->getValue('appstoreenabled', true)) { if (OC_App::getInstallPath() === null || !is_writable(OC_App::getInstallPath()) || !is_readable(OC_App::getInstallPath()) @@ -692,7 +692,7 @@ class OC_Util { } } // Create root dir. - if ($config->getSystemValue('installed', false)) { + if ($config->getValue('installed', false)) { if (!is_dir($CONFIG_DATADIRECTORY)) { $success = @mkdir($CONFIG_DATADIRECTORY); if ($success) { @@ -1401,18 +1401,18 @@ class OC_Util { * either when the core version is higher or any app requires * an upgrade. * - * @param \OCP\IConfig $config + * @param \OC\SystemConfig $config * @return bool whether the core or any app needs an upgrade * @throws \OC\HintException When the upgrade from the given version is not allowed */ - public static function needUpgrade(\OCP\IConfig $config) { - if ($config->getSystemValue('installed', false)) { - $installedVersion = $config->getSystemValue('version', '0.0.0'); + public static function needUpgrade(\OC\SystemConfig $config) { + if ($config->getValue('installed', false)) { + $installedVersion = $config->getValue('version', '0.0.0'); $currentVersion = implode('.', \OCP\Util::getVersion()); $versionDiff = version_compare($currentVersion, $installedVersion); if ($versionDiff > 0) { return true; - } else if ($config->getSystemValue('debug', false) && $versionDiff < 0) { + } else if ($config->getValue('debug', false) && $versionDiff < 0) { // downgrade with debug $installedMajor = explode('.', $installedVersion); $installedMajor = $installedMajor[0] . '.' . $installedMajor[1]; |