]> source.dussan.org Git - nextcloud-server.git/commitdiff
Use SystemConfig instead of AllConfig for DB stuff 3907/head
authorMorris Jobke <hey@morrisjobke.de>
Fri, 17 Mar 2017 22:37:48 +0000 (16:37 -0600)
committerMorris Jobke <hey@morrisjobke.de>
Sun, 19 Mar 2017 21:53:49 +0000 (15:53 -0600)
* preparation for followup PRs to clean up the DB bootstrapping

Signed-off-by: Morris Jobke <hey@morrisjobke.de>
17 files changed:
core/Command/Check.php
core/Command/Maintenance/Install.php
core/register_command.php
lib/base.php
lib/private/Console/Application.php
lib/private/DB/ConnectionFactory.php
lib/private/Server.php
lib/private/Setup.php
lib/private/Setup/AbstractDatabase.php
lib/private/Setup/MySQL.php
lib/private/Setup/OCI.php
lib/private/Setup/PostgreSQL.php
lib/private/Setup/Sqlite.php
lib/private/legacy/util.php
lib/public/Util.php
tests/lib/SetupTest.php
tests/lib/UtilCheckServerTest.php

index 8ced96a91c3354e4b9409a3abfcc510e8726d5da..16176a171a2fbb294692c1fb50ac3a33ee8432fb 100644 (file)
  */
 namespace OC\Core\Command;
 
-use OCP\IConfig;
+use OC\SystemConfig;
 use Symfony\Component\Console\Input\InputInterface;
 use Symfony\Component\Console\Output\OutputInterface;
 
 class Check extends Base {
        /**
-        * @var IConfig
+        * @var SystemConfig
         */
        private $config;
 
-       public function __construct(IConfig $config) {
+       public function __construct(SystemConfig $config) {
                parent::__construct();
                $this->config = $config;
        }
index 4b76a1f608cfd02959aa4f0df0bc0b5b1beadbfd..86180489fa46c360829cefb2d14b87c37057d00f 100644 (file)
@@ -29,7 +29,7 @@ namespace OC\Core\Command\Maintenance;
 
 use InvalidArgumentException;
 use OC\Setup;
-use OCP\IConfig;
+use OC\SystemConfig;
 use Symfony\Component\Console\Command\Command;
 use Symfony\Component\Console\Helper\QuestionHelper;
 use Symfony\Component\Console\Input\InputInterface;
@@ -40,11 +40,11 @@ use Symfony\Component\Console\Question\Question;
 class Install extends Command {
 
        /**
-        * @var IConfig
+        * @var SystemConfig
         */
        private $config;
 
-       public function __construct(IConfig $config) {
+       public function __construct(SystemConfig $config) {
                parent::__construct();
                $this->config = $config;
        }
index 288ee9590b73d47fa3d81e8d72f091ea424e439b..6a8ab2bebe2f4773eccd2ad683475b1a940bfcec 100644 (file)
@@ -35,7 +35,7 @@
 /** @var $application Symfony\Component\Console\Application */
 $application->add(new \Stecman\Component\Symfony\Console\BashCompletion\CompletionCommand());
 $application->add(new OC\Core\Command\Status);
-$application->add(new OC\Core\Command\Check(\OC::$server->getConfig()));
+$application->add(new OC\Core\Command\Check(\OC::$server->getSystemConfig()));
 $infoParser = new \OC\App\InfoParser();
 $application->add(new OC\Core\Command\App\CheckCode($infoParser));
 $application->add(new OC\Core\Command\L10n\CreateJs());
@@ -83,7 +83,7 @@ if (\OC::$server->getConfig()->getSystemValue('installed', false)) {
        $application->add(new OC\Core\Command\Config\System\SetConfig(\OC::$server->getSystemConfig()));
 
        $application->add(new OC\Core\Command\Db\GenerateChangeScript());
-       $application->add(new OC\Core\Command\Db\ConvertType(\OC::$server->getConfig(), new \OC\DB\ConnectionFactory(\OC::$server->getConfig())));
+       $application->add(new OC\Core\Command\Db\ConvertType(\OC::$server->getConfig(), new \OC\DB\ConnectionFactory(\OC::$server->getSystemConfig())));
 
        $application->add(new OC\Core\Command\Encryption\Disable(\OC::$server->getConfig()));
        $application->add(new OC\Core\Command\Encryption\Enable(\OC::$server->getConfig(), \OC::$server->getEncryptionManager()));
@@ -149,5 +149,5 @@ if (\OC::$server->getConfig()->getSystemValue('installed', false)) {
        $application->add(new OC\Core\Command\Security\ImportCertificate(\OC::$server->getCertificateManager(null)));
        $application->add(new OC\Core\Command\Security\RemoveCertificate(\OC::$server->getCertificateManager(null)));
 } else {
-       $application->add(new OC\Core\Command\Maintenance\Install(\OC::$server->getConfig()));
+       $application->add(new OC\Core\Command\Maintenance\Install(\OC::$server->getSystemConfig()));
 }
index 04b6d82b1df574d26233e5e2239b6b4c82a4b3b7..a6601a2dd67a23aebc10c39421e0e846b54d1a42 100644 (file)
@@ -658,7 +658,7 @@ class OC {
                self::performSameSiteCookieProtection();
 
                if (!defined('OC_CONSOLE')) {
-                       $errors = OC_Util::checkServer(\OC::$server->getConfig());
+                       $errors = OC_Util::checkServer(\OC::$server->getSystemConfig());
                        if (count($errors) > 0) {
                                if (self::$CLI) {
                                        // Convert l10n string into regular string for usage in database
@@ -911,7 +911,7 @@ class OC {
                // Check if Nextcloud is installed or in maintenance (update) mode
                if (!$systemConfig->getValue('installed', false)) {
                        \OC::$server->getSession()->clear();
-                       $setupHelper = new OC\Setup(\OC::$server->getConfig(), \OC::$server->getIniWrapper(),
+                       $setupHelper = new OC\Setup(\OC::$server->getSystemConfig(), \OC::$server->getIniWrapper(),
                                \OC::$server->getL10N('lib'), \OC::$server->getThemingDefaults(), \OC::$server->getLogger(),
                                \OC::$server->getSecureRandom());
                        $controller = new OC\Core\Controller\SetupController($setupHelper);
index f7806ba01a7f095f9287a2d5618db4fa4fb8860d..7d2f03d593e53e69ffb875b2798071200f76720c 100644 (file)
@@ -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']);
index 1b53cd4b7c0c544877b67cacc0f1a3db86f84fc0..d8f1fb2480df4d5179df1f090bd9d15d7ed7cc95 100644 (file)
@@ -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;
                }
index 969b65f95538c9ee51efe17c483e492bfc7018df..24cd8b386848e2ecede452f024b37db5c8ecb2f8 100644 (file)
@@ -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;
index 82338b40ce5bc27cdf9c903615888a83eac101c6..7a2957b5fb38a8f9017f35e5ad5fe3256419d7fc 100644 (file)
@@ -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";
index dbf46888ffe3c56eec58f4db1ccdb2ef83f43425..c554e569a634ce1e281991202c2eee734dc5f194 100644 (file)
@@ -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);
        }
 
        /**
index f4ba0e7326ad44da414f69bc1f045416b92fa634..9998ca401d9a292124e2763c5d81cf7a66fae7ec 100644 (file)
@@ -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,
                ]);
index 2a20cfa83605ff334d910cdb0114ae5e48da0be3..0538b3da98bfa4100e28b3781d5ca3e780c43500 100644 (file)
@@ -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);
index c01e5bc0332bc623eae6bb30d93446a719476c42..be3ac007493b63684d5bdf21e1c3055480483d5d 100644 (file)
@@ -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();
index 4d860103b6018f33e7b5648eb77f63c04c326f49..87c0b82682fcb03e4586091f7ec939264ea06db6 100644 (file)
@@ -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")) {
index 82fb07eb95aa910b820a6b70acb400570a704475..7f351c5b00e35048237ed14d9f4ddfd33b1ec876 100644 (file)
@@ -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];
index edda6c232616944aa226d56b5a2d23714a41b3b7..c2324e59bd4d3c64fa38d14bc8ec59046d2431e0 100644 (file)
@@ -703,7 +703,7 @@ class Util {
         */
        public static function needUpgrade() {
                if (!isset(self::$needUpgradeCache)) {
-                       self::$needUpgradeCache=\OC_Util::needUpgrade(\OC::$server->getConfig());
+                       self::$needUpgradeCache=\OC_Util::needUpgrade(\OC::$server->getSystemConfig());
                }               
                return self::$needUpgradeCache;
        }
index acbce938a25d43f452ab8f93bee3eec7f642cb48..d0e38cf407f68ca45762b268ceae7b1418c51cfb 100644 (file)
@@ -9,14 +9,14 @@
 namespace Test;
 
 use bantu\IniGetWrapper\IniGetWrapper;
-use OCP\IConfig;
+use OC\SystemConfig;
 use OCP\IL10N;
 use OCP\ILogger;
 use OCP\Security\ISecureRandom;
 
 class SetupTest extends \Test\TestCase {
 
-       /** @var IConfig | \PHPUnit_Framework_MockObject_MockObject */
+       /** @var SystemConfig | \PHPUnit_Framework_MockObject_MockObject */
        protected $config;
        /** @var \bantu\IniGetWrapper\IniGetWrapper | \PHPUnit_Framework_MockObject_MockObject */
        private $iniWrapper;
@@ -34,7 +34,7 @@ class SetupTest extends \Test\TestCase {
        protected function setUp() {
                parent::setUp();
 
-               $this->config = $this->createMock(IConfig::class);
+               $this->config = $this->createMock(SystemConfig::class);
                $this->iniWrapper = $this->createMock(IniGetWrapper::class);
                $this->l10n = $this->createMock(IL10N::class);
                $this->defaults = $this->createMock(\OC_Defaults::class);
@@ -49,7 +49,7 @@ class SetupTest extends \Test\TestCase {
        public function testGetSupportedDatabasesWithOneWorking() {
                $this->config
                        ->expects($this->once())
-                       ->method('getSystemValue')
+                       ->method('getValue')
                        ->will($this->returnValue(
                                array('sqlite', 'mysql', 'oci')
                        ));
@@ -72,7 +72,7 @@ class SetupTest extends \Test\TestCase {
        public function testGetSupportedDatabasesWithNoWorking() {
                $this->config
                        ->expects($this->once())
-                       ->method('getSystemValue')
+                       ->method('getValue')
                        ->will($this->returnValue(
                                array('sqlite', 'mysql', 'oci', 'pgsql')
                        ));
@@ -92,7 +92,7 @@ class SetupTest extends \Test\TestCase {
        public function testGetSupportedDatabasesWithAllWorking() {
                $this->config
                        ->expects($this->once())
-                       ->method('getSystemValue')
+                       ->method('getValue')
                        ->will($this->returnValue(
                                array('sqlite', 'mysql', 'pgsql', 'oci')
                        ));
@@ -121,7 +121,7 @@ class SetupTest extends \Test\TestCase {
        public function testGetSupportedDatabaseException() {
                $this->config
                        ->expects($this->once())
-                       ->method('getSystemValue')
+                       ->method('getValue')
                        ->will($this->returnValue('NotAnArray'));
                $this->setupClass->getSupportedDatabases();
        }
index b1152e97256ebb3a93d12d5dd1ac485726441d3f..c597a6b770b59d06ff12d0035d5026fa4201d279 100644 (file)
@@ -19,17 +19,17 @@ class UtilCheckServerTest extends \Test\TestCase {
 
        /**
         * @param array $systemOptions
-        * @return \OCP\IConfig | \PHPUnit_Framework_MockObject_MockObject
+        * @return \OC\SystemConfig | \PHPUnit_Framework_MockObject_MockObject
         */
        protected function getConfig($systemOptions) {
                $systemOptions['datadirectory'] = $this->datadir;
                $systemOptions['appstoreenabled'] = false; //it's likely that there is no app folder we can write in
-               $config = $this->getMockBuilder('\OCP\IConfig')
+               $config = $this->getMockBuilder('\OC\SystemConfig')
                        ->disableOriginalConstructor()
                        ->getMock();
 
                $config->expects($this->any())
-                       ->method('getSystemValue')
+                       ->method('getValue')
                        ->will($this->returnCallback(function ($key, $default) use ($systemOptions) {
                                return isset($systemOptions[$key]) ? $systemOptions[$key] : $default;
                        }));