Remove IAppConfig::getValue

Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
This commit is contained in:
Roeland Jago Douma 2018-01-17 21:10:40 +01:00
parent ee2617d88c
commit 09f8a755ec
No known key found for this signature in database
GPG Key ID: F941078878347C0C
13 changed files with 31 additions and 46 deletions

View File

@ -152,7 +152,7 @@ class AllConfig implements \OCP\IConfig {
* @return string[] the keys stored for the app * @return string[] the keys stored for the app
*/ */
public function getAppKeys($appName) { public function getAppKeys($appName) {
\OC::$server->query(\OC\AppConfig::class)->getKeys($appName); return \OC::$server->query(\OC\AppConfig::class)->getKeys($appName);
} }
/** /**
@ -175,7 +175,7 @@ class AllConfig implements \OCP\IConfig {
* @return string the saved value * @return string the saved value
*/ */
public function getAppValue($appName, $key, $default = '') { public function getAppValue($appName, $key, $default = '') {
return \OC::$server->getAppConfig()->getValue($appName, $key, $default); return \OC::$server->query(\OC\AppConfig::class)->getValue($appName, $key, $default);
} }
/** /**

View File

@ -32,10 +32,10 @@
namespace OC\App; namespace OC\App;
use OC\AppConfig;
use OCP\App\AppPathNotFoundException; use OCP\App\AppPathNotFoundException;
use OCP\App\IAppManager; use OCP\App\IAppManager;
use OCP\App\ManagerEvent; use OCP\App\ManagerEvent;
use OCP\IAppConfig;
use OCP\ICacheFactory; use OCP\ICacheFactory;
use OCP\IGroupManager; use OCP\IGroupManager;
use OCP\IUser; use OCP\IUser;
@ -59,7 +59,7 @@ class AppManager implements IAppManager {
/** @var IUserSession */ /** @var IUserSession */
private $userSession; private $userSession;
/** @var IAppConfig */ /** @var AppConfig */
private $appConfig; private $appConfig;
/** @var IGroupManager */ /** @var IGroupManager */
@ -82,13 +82,13 @@ class AppManager implements IAppManager {
/** /**
* @param IUserSession $userSession * @param IUserSession $userSession
* @param IAppConfig $appConfig * @param AppConfig $appConfig
* @param IGroupManager $groupManager * @param IGroupManager $groupManager
* @param ICacheFactory $memCacheFactory * @param ICacheFactory $memCacheFactory
* @param EventDispatcherInterface $dispatcher * @param EventDispatcherInterface $dispatcher
*/ */
public function __construct(IUserSession $userSession, public function __construct(IUserSession $userSession,
IAppConfig $appConfig, AppConfig $appConfig,
IGroupManager $groupManager, IGroupManager $groupManager,
ICacheFactory $memCacheFactory, ICacheFactory $memCacheFactory,
EventDispatcherInterface $dispatcher) { EventDispatcherInterface $dispatcher) {

View File

@ -128,7 +128,6 @@ class AppConfig implements IAppConfig {
* @param string $key key * @param string $key key
* @param string $default = null, default value if the key does not exist * @param string $default = null, default value if the key does not exist
* @return string the value or $default * @return string the value or $default
* @deprecated 8.0.0 use method getAppValue of \OCP\IConfig
* *
* This function gets a value from the appconfig table. If the key does * This function gets a value from the appconfig table. If the key does
* not exist the default value will be returned * not exist the default value will be returned

View File

@ -133,7 +133,7 @@ class Installer {
//install the database //install the database
if(is_file($basedir.'/appinfo/database.xml')) { if(is_file($basedir.'/appinfo/database.xml')) {
if (\OC::$server->getAppConfig()->getValue($info['id'], 'installed_version') === null) { if (\OC::$server->getConfig()->getAppValue($info['id'], 'installed_version') === null) {
OC_DB::createDbFromStructure($basedir.'/appinfo/database.xml'); OC_DB::createDbFromStructure($basedir.'/appinfo/database.xml');
} else { } else {
OC_DB::updateDbFromStructure($basedir.'/appinfo/database.xml'); OC_DB::updateDbFromStructure($basedir.'/appinfo/database.xml');

View File

@ -677,7 +677,7 @@ class Server extends ServerContainer implements IServerContainer {
$this->registerService(AppManager::class, function (Server $c) { $this->registerService(AppManager::class, function (Server $c) {
return new \OC\App\AppManager( return new \OC\App\AppManager(
$c->getUserSession(), $c->getUserSession(),
$c->getAppConfig(), $c->query(\OC\AppConfig::class),
$c->getGroupManager(), $c->getGroupManager(),
$c->getMemCacheFactory(), $c->getMemCacheFactory(),
$c->getEventDispatcher() $c->getEventDispatcher()

View File

@ -81,7 +81,7 @@ class Share extends Constants {
* @return boolean true if backend is registered or false if error * @return boolean true if backend is registered or false if error
*/ */
public static function registerBackend($itemType, $class, $collectionOf = null, $supportedFileExtensions = null) { public static function registerBackend($itemType, $class, $collectionOf = null, $supportedFileExtensions = null) {
if (\OC::$server->getAppConfig()->getValue('core', 'shareapi_enabled', 'yes') == 'yes') { if (\OC::$server->getConfig()->getAppValue('core', 'shareapi_enabled', 'yes') == 'yes') {
if (!isset(self::$backendTypes[$itemType])) { if (!isset(self::$backendTypes[$itemType])) {
self::$backendTypes[$itemType] = array( self::$backendTypes[$itemType] = array(
'class' => $class, 'class' => $class,
@ -540,7 +540,7 @@ class Share extends Constants {
$shareWith['users'] = array_diff($userIds, array($uidOwner)); $shareWith['users'] = array_diff($userIds, array($uidOwner));
} else if ($shareType === self::SHARE_TYPE_LINK) { } else if ($shareType === self::SHARE_TYPE_LINK) {
$updateExistingShare = false; $updateExistingShare = false;
if (\OC::$server->getAppConfig()->getValue('core', 'shareapi_allow_links', 'yes') == 'yes') { if (\OC::$server->getConfig()->getAppValue('core', 'shareapi_allow_links', 'yes') == 'yes') {
// IF the password is changed via the old ajax endpoint verify it before deleting the old share // IF the password is changed via the old ajax endpoint verify it before deleting the old share
if ($passwordChanged === true) { if ($passwordChanged === true) {
@ -977,7 +977,7 @@ class Share extends Constants {
*/ */
public static function isResharingAllowed() { public static function isResharingAllowed() {
if (!isset(self::$isResharingAllowed)) { if (!isset(self::$isResharingAllowed)) {
if (\OC::$server->getAppConfig()->getValue('core', 'shareapi_allow_resharing', 'yes') == 'yes') { if (\OC::$server->getConfig()->getAppValue('core', 'shareapi_allow_resharing', 'yes') == 'yes') {
self::$isResharingAllowed = true; self::$isResharingAllowed = true;
} else { } else {
self::$isResharingAllowed = false; self::$isResharingAllowed = false;
@ -1082,7 +1082,7 @@ class Share extends Constants {
public static function getItems($itemType, $item = null, $shareType = null, $shareWith = null, public static function getItems($itemType, $item = null, $shareType = null, $shareWith = null,
$uidOwner = null, $format = self::FORMAT_NONE, $parameters = null, $limit = -1, $uidOwner = null, $format = self::FORMAT_NONE, $parameters = null, $limit = -1,
$includeCollections = false, $itemShareWithBySource = false, $checkExpireDate = true) { $includeCollections = false, $itemShareWithBySource = false, $checkExpireDate = true) {
if (\OC::$server->getAppConfig()->getValue('core', 'shareapi_enabled', 'yes') != 'yes') { if (\OC::$server->getConfig()->getAppValue('core', 'shareapi_enabled', 'yes') != 'yes') {
return array(); return array();
} }
$backend = self::getBackend($itemType); $backend = self::getBackend($itemType);
@ -1121,7 +1121,7 @@ class Share extends Constants {
$queryArgs = array($itemType); $queryArgs = array($itemType);
} }
} }
if (\OC::$server->getAppConfig()->getValue('core', 'shareapi_allow_links', 'yes') !== 'yes') { if (\OC::$server->getConfig()->getAppValue('core', 'shareapi_allow_links', 'yes') !== 'yes') {
$where .= ' AND `share_type` != ?'; $where .= ' AND `share_type` != ?';
$queryArgs[] = self::SHARE_TYPE_LINK; $queryArgs[] = self::SHARE_TYPE_LINK;
} }
@ -2144,7 +2144,7 @@ class Share extends Constants {
* @return bool * @return bool
*/ */
public static function shareWithGroupMembersOnly() { public static function shareWithGroupMembersOnly() {
$value = \OC::$server->getAppConfig()->getValue('core', 'shareapi_only_share_with_group_members', 'no'); $value = \OC::$server->getConfig()->getAppValue('core', 'shareapi_only_share_with_group_members', 'no');
return ($value === 'yes') ? true : false; return ($value === 'yes') ? true : false;
} }

View File

@ -301,7 +301,7 @@ class OC_App {
\OC::$server->getAppConfig()->setValue($app, 'types', $appTypes); \OC::$server->getAppConfig()->setValue($app, 'types', $appTypes);
if (\OC::$server->getAppManager()->hasProtectedAppType($appData['types'])) { if (\OC::$server->getAppManager()->hasProtectedAppType($appData['types'])) {
$enabled = \OC::$server->getAppConfig()->getValue($app, 'enabled', 'yes'); $enabled = \OC::$server->getConfig()->getAppValue($app, 'enabled', 'yes');
if ($enabled !== 'yes' && $enabled !== 'no') { if ($enabled !== 'yes' && $enabled !== 'no') {
\OC::$server->getAppConfig()->setValue($app, 'enabled', 'yes'); \OC::$server->getAppConfig()->setValue($app, 'enabled', 'yes');
} }
@ -803,7 +803,7 @@ class OC_App {
continue; continue;
} }
$enabled = \OC::$server->getAppConfig()->getValue($app, 'enabled', 'no'); $enabled = \OC::$server->getConfig()->getAppValue($app, 'enabled', 'no');
$info['groups'] = null; $info['groups'] = null;
if ($enabled === 'yes') { if ($enabled === 'yes') {
$active = true; $active = true;

View File

@ -300,8 +300,7 @@ class OC_Util {
* @suppress PhanDeprecatedFunction * @suppress PhanDeprecatedFunction
*/ */
public static function isPublicLinkPasswordRequired() { public static function isPublicLinkPasswordRequired() {
$appConfig = \OC::$server->getAppConfig(); $enforcePassword = \OC::$server->getConfig()->getAppValue('core', 'shareapi_enforce_links_password', 'no');
$enforcePassword = $appConfig->getValue('core', 'shareapi_enforce_links_password', 'no');
return ($enforcePassword === 'yes') ? true : false; return ($enforcePassword === 'yes') ? true : false;
} }
@ -1116,7 +1115,7 @@ class OC_Util {
if (isset($_REQUEST['redirect_url']) && strpos($_REQUEST['redirect_url'], '@') === false) { if (isset($_REQUEST['redirect_url']) && strpos($_REQUEST['redirect_url'], '@') === false) {
$location = $urlGenerator->getAbsoluteURL(urldecode($_REQUEST['redirect_url'])); $location = $urlGenerator->getAbsoluteURL(urldecode($_REQUEST['redirect_url']));
} else { } else {
$defaultPage = \OC::$server->getAppConfig()->getValue('core', 'defaultpage'); $defaultPage = \OC::$server->getConfig()->getAppValue('core', 'defaultpage');
if ($defaultPage) { if ($defaultPage) {
$location = $urlGenerator->getAbsoluteURL($defaultPage); $location = $urlGenerator->getAbsoluteURL($defaultPage);
} else { } else {

View File

@ -40,20 +40,6 @@ interface IAppConfig {
*/ */
public function hasKey($app, $key); public function hasKey($app, $key);
/**
* Gets the config value
* @param string $app app
* @param string $key key
* @param string $default = null, default value if the key does not exist
* @return string the value or $default
* @deprecated 8.0.0 use method getAppValue of \OCP\IConfig
*
* This function gets a value from the appconfig table. If the key does
* not exist the default value will be returned
* @since 7.0.0
*/
public function getValue($app, $key, $default = null);
/** /**
* get multiply values, either the app or key can be used as wildcard by setting it to false * get multiply values, either the app or key can be used as wildcard by setting it to false
* *

View File

@ -10,6 +10,7 @@
namespace Test\App; namespace Test\App;
use OC\App\AppManager; use OC\App\AppManager;
use OC\AppConfig;
use OC\Group\Group; use OC\Group\Group;
use OC\User\User; use OC\User\User;
use OCP\App\AppPathNotFoundException; use OCP\App\AppPathNotFoundException;
@ -31,11 +32,11 @@ use Test\TestCase;
*/ */
class AppManagerTest extends TestCase { class AppManagerTest extends TestCase {
/** /**
* @return IAppConfig|\PHPUnit_Framework_MockObject_MockObject * @return AppConfig|\PHPUnit_Framework_MockObject_MockObject
*/ */
protected function getAppConfig() { protected function getAppConfig() {
$appConfig = array(); $appConfig = array();
$config = $this->createMock(IAppConfig::class); $config = $this->createMock(AppConfig::class);
$config->expects($this->any()) $config->expects($this->any())
->method('getValue') ->method('getValue')
@ -75,7 +76,7 @@ class AppManagerTest extends TestCase {
/** @var IGroupManager|\PHPUnit_Framework_MockObject_MockObject */ /** @var IGroupManager|\PHPUnit_Framework_MockObject_MockObject */
protected $groupManager; protected $groupManager;
/** @var IAppConfig|\PHPUnit_Framework_MockObject_MockObject */ /** @var AppConfig|\PHPUnit_Framework_MockObject_MockObject */
protected $appConfig; protected $appConfig;
/** @var ICache|\PHPUnit_Framework_MockObject_MockObject */ /** @var ICache|\PHPUnit_Framework_MockObject_MockObject */

View File

@ -542,7 +542,7 @@ class AppTest extends \Test\TestCase {
* *
* @param IAppConfig $appConfig app config mock * @param IAppConfig $appConfig app config mock
*/ */
private function registerAppConfig(IAppConfig $appConfig) { private function registerAppConfig(AppConfig $appConfig) {
$this->overwriteService('AppConfig', $appConfig); $this->overwriteService('AppConfig', $appConfig);
$this->overwriteService('AppManager', new \OC\App\AppManager( $this->overwriteService('AppManager', new \OC\App\AppManager(
\OC::$server->getUserSession(), \OC::$server->getUserSession(),

View File

@ -284,11 +284,11 @@ class ViewTest extends \Test\TestCase {
// Reset sharing disabled for users cache // Reset sharing disabled for users cache
self::invokePrivate(\OC::$server->getShareManager(), 'sharingDisabledForUsersCache', [new CappedMemoryCache()]); self::invokePrivate(\OC::$server->getShareManager(), 'sharingDisabledForUsersCache', [new CappedMemoryCache()]);
$appConfig = \OC::$server->getAppConfig(); $config = \OC::$server->getConfig();
$oldExcludeGroupsFlag = $appConfig->getValue('core', 'shareapi_exclude_groups', 'no'); $oldExcludeGroupsFlag = $config->getAppValue('core', 'shareapi_exclude_groups', 'no');
$oldExcludeGroupsList = $appConfig->getValue('core', 'shareapi_exclude_groups_list', ''); $oldExcludeGroupsList = $config->getAppValue('core', 'shareapi_exclude_groups_list', '');
$appConfig->setValue('core', 'shareapi_exclude_groups', $excludeGroups); $config->setAppValue('core', 'shareapi_exclude_groups', $excludeGroups);
$appConfig->setValue('core', 'shareapi_exclude_groups_list', $excludeGroupsList); $config->setAppValue('core', 'shareapi_exclude_groups_list', $excludeGroupsList);
$storage1 = $this->getTestStorage(); $storage1 = $this->getTestStorage();
$storage2 = $this->getTestStorage(); $storage2 = $this->getTestStorage();
@ -303,8 +303,8 @@ class ViewTest extends \Test\TestCase {
$folderContent = $view->getDirectoryContent('mount'); $folderContent = $view->getDirectoryContent('mount');
$this->assertEquals($expectedShareable, $folderContent[0]->isShareable()); $this->assertEquals($expectedShareable, $folderContent[0]->isShareable());
$appConfig->setValue('core', 'shareapi_exclude_groups', $oldExcludeGroupsFlag); $config->setAppValue('core', 'shareapi_exclude_groups', $oldExcludeGroupsFlag);
$appConfig->setValue('core', 'shareapi_exclude_groups_list', $oldExcludeGroupsList); $config->setAppValue('core', 'shareapi_exclude_groups_list', $oldExcludeGroupsList);
// Reset sharing disabled for users cache // Reset sharing disabled for users cache
self::invokePrivate(\OC::$server->getShareManager(), 'sharingDisabledForUsersCache', [new CappedMemoryCache()]); self::invokePrivate(\OC::$server->getShareManager(), 'sharingDisabledForUsersCache', [new CappedMemoryCache()]);

View File

@ -103,7 +103,7 @@ class ShareTest extends \Test\TestCase {
\OC\Share\Share::registerBackend('test', 'Test\Share\Backend'); \OC\Share\Share::registerBackend('test', 'Test\Share\Backend');
\OC_Hook::clear('OCP\\Share'); \OC_Hook::clear('OCP\\Share');
\OC::registerShareHooks(); \OC::registerShareHooks();
$this->resharing = \OC::$server->getAppConfig()->getValue('core', 'shareapi_allow_resharing', 'yes'); $this->resharing = \OC::$server->getConfig()->getAppValue('core', 'shareapi_allow_resharing', 'yes');
\OC::$server->getAppConfig()->setValue('core', 'shareapi_allow_resharing', 'yes'); \OC::$server->getAppConfig()->setValue('core', 'shareapi_allow_resharing', 'yes');
// 20 Minutes in the past, 20 minutes in the future. // 20 Minutes in the past, 20 minutes in the future.