From: Roeland Jago Douma Date: Fri, 18 Dec 2015 09:33:30 +0000 (+0100) Subject: Get rid of legacy OC_Config X-Git-Tag: v9.0beta1~456^2~2 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=82bf99c0cfd764b25d1442cf199f219cd852ff69;p=nextcloud-server.git Get rid of legacy OC_Config We were still using the lecagy class OC_Config all over the place. Which was a wrapper around the new class OC\Config --- diff --git a/lib/base.php b/lib/base.php index 8f1432d6fb9..887499b58a5 100644 --- a/lib/base.php +++ b/lib/base.php @@ -112,6 +112,11 @@ class OC { */ public static $server = null; + /** + * @var \OC\Config + */ + public static $config = null; + /** * @throws \RuntimeException when the 3rdparty directory is missing or * the app path list is empty or contains an invalid path @@ -124,7 +129,7 @@ class OC { } else { self::$configDir = OC::$SERVERROOT . '/config/'; } - OC_Config::$object = new \OC\Config(self::$configDir); + self::$config = new \OC\Config(self::$configDir); OC::$SUBURI = str_replace("\\", "/", substr(realpath($_SERVER["SCRIPT_FILENAME"]), strlen(OC::$SERVERROOT))); /** @@ -152,7 +157,7 @@ class OC { if (OC::$CLI) { - OC::$WEBROOT = OC_Config::getValue('overwritewebroot', ''); + OC::$WEBROOT = \OC::$config->getValue('overwritewebroot', ''); } else { if (substr($scriptName, 0 - strlen(OC::$SUBURI)) === OC::$SUBURI) { OC::$WEBROOT = substr($scriptName, 0, 0 - strlen(OC::$SUBURI)); @@ -165,7 +170,7 @@ class OC { // This most likely means that we are calling from CLI. // However some cron jobs still need to generate // a web URL, so we use overwritewebroot as a fallback. - OC::$WEBROOT = OC_Config::getValue('overwritewebroot', ''); + OC::$WEBROOT = \OC::$config->getValue('overwritewebroot', ''); } // Resolve /owncloud to /owncloud/ to ensure to always have a trailing @@ -178,8 +183,8 @@ class OC { } // search the 3rdparty folder - OC::$THIRDPARTYROOT = OC_Config::getValue('3rdpartyroot', null); - OC::$THIRDPARTYWEBROOT = OC_Config::getValue('3rdpartyurl', null); + OC::$THIRDPARTYROOT = \OC::$config->getValue('3rdpartyroot', null); + OC::$THIRDPARTYWEBROOT = \OC::$config->getValue('3rdpartyurl', null); if (empty(OC::$THIRDPARTYROOT) && empty(OC::$THIRDPARTYWEBROOT)) { if (file_exists(OC::$SERVERROOT . '/3rdparty')) { @@ -197,7 +202,7 @@ class OC { } // search the apps folder - $config_paths = OC_Config::getValue('apps_paths', array()); + $config_paths = \OC::$config->getValue('apps_paths', array()); if (!empty($config_paths)) { foreach ($config_paths as $paths) { if (isset($paths['url']) && isset($paths['path'])) { diff --git a/lib/private/app.php b/lib/private/app.php index e8cc9219224..b0d2273a0cd 100644 --- a/lib/private/app.php +++ b/lib/private/app.php @@ -96,7 +96,7 @@ class OC_App { * if $types is set, only apps of those types will be loaded */ public static function loadApps($types = null) { - if (OC_Config::getValue('maintenance', false)) { + if (\OC::$config->getValue('maintenance', false)) { return false; } // Load the enabled apps here @@ -239,7 +239,7 @@ class OC_App { * @return string[] */ public static function getEnabledApps($forceRefresh = false, $all = false) { - if (!OC_Config::getValue('installed', false)) { + if (!\OC::$config->getValue('installed', false)) { return array(); } // in incognito mode or when logged out, $user will be false, @@ -374,7 +374,7 @@ class OC_App { $settings = array(); // by default, settings only contain the help menu if (OC_Util::getEditionString() === '' && - OC_Config::getValue('knowledgebaseenabled', true) == true + \OC::$config->getValue('knowledgebaseenabled', true) == true ) { $settings = array( array( @@ -455,7 +455,7 @@ class OC_App { * @return string|false */ public static function getInstallPath() { - if (OC_Config::getValue('appstoreenabled', true) == false) { + if (\OC::$config->getValue('appstoreenabled', true) == false) { return false; } diff --git a/lib/private/helper.php b/lib/private/helper.php index 72282362fe6..707f6cdccad 100644 --- a/lib/private/helper.php +++ b/lib/private/helper.php @@ -746,7 +746,7 @@ class OC_Helper { */ public static function getStorageInfo($path, $rootInfo = null) { // return storage info without adding mount points - $includeExtStorage = \OC_Config::getValue('quota_include_external_storage', false); + $includeExtStorage = \OC::$config->getValue('quota_include_external_storage', false); if (!$rootInfo) { $rootInfo = \OC\Files\Filesystem::getFileInfo($path, false); diff --git a/lib/private/legacy/config.php b/lib/private/legacy/config.php deleted file mode 100644 index 1835d4a4b1c..00000000000 --- a/lib/private/legacy/config.php +++ /dev/null @@ -1,94 +0,0 @@ - - * @author Joas Schilling - * @author Jörn Friedrich Dreyer - * @author Lukas Reschke - * @author Michael Gapczynski - * @author Morris Jobke - * @author Robin McCorkell - * - * @copyright Copyright (c) 2015, ownCloud, Inc. - * @license AGPL-3.0 - * - * This code is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License, version 3, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License, version 3, - * along with this program. If not, see - * - */ - -/** - * This class is responsible for reading and writing config.php, the very basic - * configuration file of ownCloud. - * - * @deprecated use \OC::$server->getConfig() to get an \OCP\Config instance - */ -class OC_Config { - - /** @var \OC\Config */ - public static $object; - - /** - * Lists all available config keys - * @return array an array of key names - * - * This function returns all keys saved in config.php. Please note that it - * does not return the values. - */ - public static function getKeys() { - return self::$object->getKeys(); - } - - /** - * Gets a value from config.php - * @param string $key key - * @param mixed $default = null default value - * @return mixed the value or $default - * - * This function gets the value from config.php. If it does not exist, - * $default will be returned. - */ - public static function getValue($key, $default = null) { - return self::$object->getValue($key, $default); - } - - /** - * Sets a value - * @param string $key key - * @param mixed $value value - * - * This function sets the value and writes the config.php. - * - */ - public static function setValue($key, $value) { - self::$object->setValue($key, $value); - } - - /** - * Sets and deletes values and writes the config.php - * - * @param array $configs Associative array with `key => value` pairs - * If value is null, the config key will be deleted - */ - public static function setValues(array $configs) { - self::$object->setValues($configs); - } - - /** - * Removes a key from the config - * @param string $key key - * - * This function removes a key from the config.php. - */ - public static function deleteKey($key) { - self::$object->deleteKey($key); - } -} diff --git a/lib/private/systemconfig.php b/lib/private/systemconfig.php index 94b815aebd7..d2ceeb8272d 100644 --- a/lib/private/systemconfig.php +++ b/lib/private/systemconfig.php @@ -49,7 +49,7 @@ class SystemConfig { * @return array an array of key names */ public function getKeys() { - return \OC_Config::getKeys(); + return \OC::$config->getKeys(); } /** @@ -59,7 +59,7 @@ class SystemConfig { * @param mixed $value the value that should be stored */ public function setValue($key, $value) { - \OC_Config::setValue($key, $value); + \OC::$config->setValue($key, $value); } /** @@ -69,7 +69,7 @@ class SystemConfig { * If value is null, the config key will be deleted */ public function setValues(array $configs) { - \OC_Config::setValues($configs); + \OC::$config->setValues($configs); } /** @@ -80,7 +80,7 @@ class SystemConfig { * @return mixed the value or $default */ public function getValue($key, $default = '') { - return \OC_Config::getValue($key, $default); + return \OC::$config->getValue($key, $default); } /** @@ -106,7 +106,7 @@ class SystemConfig { * @param string $key the key of the value, under which it was saved */ public function deleteValue($key) { - \OC_Config::deleteKey($key); + \OC::$config->deleteKey($key); } /** diff --git a/lib/private/user.php b/lib/private/user.php index f806aa07251..4e395a3f7a3 100644 --- a/lib/private/user.php +++ b/lib/private/user.php @@ -130,7 +130,7 @@ class OC_User { */ public static function setupBackends() { OC_App::loadApps(array('prelogin')); - $backends = OC_Config::getValue('user_backends', array()); + $backends = \OC::$config->getValue('user_backends', array()); foreach ($backends as $i => $config) { $class = $config['class']; $arguments = $config['arguments']; @@ -498,7 +498,7 @@ class OC_User { if ($user) { return $user->getHome(); } else { - return OC_Config::getValue('datadirectory', OC::$SERVERROOT . '/data') . '/' . $uid; + return \OC::$config->getValue('datadirectory', OC::$SERVERROOT . '/data') . '/' . $uid; } } diff --git a/lib/private/util.php b/lib/private/util.php index c63befb3f32..193a446d60a 100644 --- a/lib/private/util.php +++ b/lib/private/util.php @@ -72,7 +72,7 @@ class OC_Util { private static function initLocalStorageRootFS() { // mount local file backend as root - $configDataDirectory = OC_Config::getValue("datadirectory", OC::$SERVERROOT . "/data"); + $configDataDirectory = \OC::$config->getValue("datadirectory", OC::$SERVERROOT . "/data"); //first set up the local "root" storage \OC\Files\Filesystem::initMountManager(); if (!self::$rootMounted) { @@ -184,7 +184,7 @@ class OC_Util { OC_Hook::emit('OC_Filesystem', 'preSetup', array('user' => $user)); //check if we are using an object storage - $objectStore = OC_Config::getValue('objectstore'); + $objectStore = \OC::$config->getValue('objectstore'); if (isset($objectStore)) { self::initObjectStoreRootFS($objectStore); } else { @@ -848,7 +848,7 @@ class OC_Util { public static function checkDatabaseVersion() { $l = \OC::$server->getL10N('lib'); $errors = array(); - $dbType = \OC_Config::getValue('dbtype', 'sqlite'); + $dbType = \OC::$config->getValue('dbtype', 'sqlite'); if ($dbType === 'pgsql') { // check PostgreSQL version try { @@ -1108,11 +1108,11 @@ class OC_Util { * @return string */ public static function getInstanceId() { - $id = OC_Config::getValue('instanceid', null); + $id = \OC::$config->getValue('instanceid', null); if (is_null($id)) { // We need to guarantee at least one letter in instanceid so it can be used as the session_name $id = 'oc' . \OC::$server->getSecureRandom()->getLowStrengthGenerator()->generate(10, \OCP\Security\ISecureRandom::CHAR_LOWER.\OCP\Security\ISecureRandom::CHAR_DIGITS); - OC_Config::$object->setValue('instanceid', $id); + \OC::$config->setValue('instanceid', $id); } return $id; } @@ -1364,7 +1364,7 @@ class OC_Util { * @return string the theme */ public static function getTheme() { - $theme = OC_Config::getValue("theme", ''); + $theme = \OC::$config->getValue("theme", ''); if ($theme === '') { if (is_dir(OC::$SERVERROOT . '/themes/default')) {