Remove IAppConfig::setValue

Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
This commit is contained in:
Roeland Jago Douma 2018-01-17 21:14:09 +01:00
parent 09f8a755ec
commit 1e7b20f615
No known key found for this signature in database
GPG key ID: F941078878347C0C
7 changed files with 18 additions and 32 deletions

View file

@ -62,8 +62,8 @@ class ApiTest extends TestCase {
protected function setUp() { protected function setUp() {
parent::setUp(); parent::setUp();
\OC::$server->getAppConfig()->setValue('core', 'shareapi_exclude_groups', 'no'); \OC::$server->getConfig()->setAppValue('core', 'shareapi_exclude_groups', 'no');
\OC::$server->getAppConfig()->setValue('core', 'shareapi_expire_after_n_days', '7'); \OC::$server->getConfig()->setAppValue('core', 'shareapi_expire_after_n_days', '7');
$this->folder = self::TEST_FOLDER_NAME; $this->folder = self::TEST_FOLDER_NAME;
$this->subfolder = '/subfolder_share_api_test'; $this->subfolder = '/subfolder_share_api_test';
@ -239,8 +239,8 @@ class ApiTest extends TestCase {
function testEnfoceLinkPassword() { function testEnfoceLinkPassword() {
$password = md5(time()); $password = md5(time());
$appConfig = \OC::$server->getAppConfig(); $config = \OC::$server->getConfig();
$appConfig->setValue('core', 'shareapi_enforce_links_password', 'yes'); $config->setAppValue('core', 'shareapi_enforce_links_password', 'yes');
$ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1); $ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1);
try { try {
@ -287,7 +287,7 @@ class ApiTest extends TestCase {
$ocs->deleteShare($data['id']); $ocs->deleteShare($data['id']);
$ocs->cleanup(); $ocs->cleanup();
$appConfig->setValue('core', 'shareapi_enforce_links_password', 'no'); $config->setAppValue('core', 'shareapi_enforce_links_password', 'no');
} }
/** /**
@ -296,7 +296,7 @@ class ApiTest extends TestCase {
function testSharePermissions() { function testSharePermissions() {
// sharing file to a user should work if shareapi_exclude_groups is set // sharing file to a user should work if shareapi_exclude_groups is set
// to no // to no
\OC::$server->getAppConfig()->setValue('core', 'shareapi_exclude_groups', 'no'); \OC::$server->getConfig()->setAppValue('core', 'shareapi_exclude_groups', 'no');
$ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1); $ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1);
$result = $ocs->createShare($this->filename, \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER2); $result = $ocs->createShare($this->filename, \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER2);
@ -311,8 +311,8 @@ class ApiTest extends TestCase {
$ocs->cleanup(); $ocs->cleanup();
// exclude groups, but not the group the user belongs to. Sharing should still work // exclude groups, but not the group the user belongs to. Sharing should still work
\OC::$server->getAppConfig()->setValue('core', 'shareapi_exclude_groups', 'yes'); \OC::$server->getConfig()->setAppValue('core', 'shareapi_exclude_groups', 'yes');
\OC::$server->getAppConfig()->setValue('core', 'shareapi_exclude_groups_list', 'admin,group1,group2'); \OC::$server->getConfig()->setAppValue('core', 'shareapi_exclude_groups_list', 'admin,group1,group2');
$ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1); $ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1);
$result = $ocs->createShare($this->filename, \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER2); $result = $ocs->createShare($this->filename, \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER2);
@ -327,15 +327,15 @@ class ApiTest extends TestCase {
$ocs->cleanup(); $ocs->cleanup();
// now we exclude the group the user belongs to ('group'), sharing should fail now // now we exclude the group the user belongs to ('group'), sharing should fail now
\OC::$server->getAppConfig()->setValue('core', 'shareapi_exclude_groups_list', 'admin,group'); \OC::$server->getConfig()->setAppValue('core', 'shareapi_exclude_groups_list', 'admin,group');
$ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1); $ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1);
$ocs->createShare($this->filename, \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER2); $ocs->createShare($this->filename, \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER2);
$ocs->cleanup(); $ocs->cleanup();
// cleanup // cleanup
\OC::$server->getAppConfig()->setValue('core', 'shareapi_exclude_groups', 'no'); \OC::$server->getConfig()->setAppValue('core', 'shareapi_exclude_groups', 'no');
\OC::$server->getAppConfig()->setValue('core', 'shareapi_exclude_groups_list', ''); \OC::$server->getConfig()->setAppValue('core', 'shareapi_exclude_groups_list', '');
} }

View file

@ -163,7 +163,7 @@ class AllConfig implements \OCP\IConfig {
* @param string|float|int $value the value that should be stored * @param string|float|int $value the value that should be stored
*/ */
public function setAppValue($appName, $key, $value) { public function setAppValue($appName, $key, $value) {
\OC::$server->getAppConfig()->setValue($appName, $key, $value); \OC::$server->query(\OC\AppConfig::class)->setValue($appName, $key, $value);
} }
/** /**

View file

@ -162,7 +162,6 @@ class AppConfig implements IAppConfig {
* @param string $key key * @param string $key key
* @param string|float|int $value value * @param string|float|int $value value
* @return bool True if the value was inserted or updated, false if the value was the same * @return bool True if the value was inserted or updated, false if the value was the same
* @deprecated 8.0.0 use method setAppValue of \OCP\IConfig
*/ */
public function setValue($app, $key, $value) { public function setValue($app, $key, $value) {
if (!$this->hasKey($app, $key)) { if (!$this->hasKey($app, $key)) {

View file

@ -298,12 +298,12 @@ class OC_App {
$appData['types'] = []; $appData['types'] = [];
} }
\OC::$server->getAppConfig()->setValue($app, 'types', $appTypes); \OC::$server->getConfig()->setAppValue($app, 'types', $appTypes);
if (\OC::$server->getAppManager()->hasProtectedAppType($appData['types'])) { if (\OC::$server->getAppManager()->hasProtectedAppType($appData['types'])) {
$enabled = \OC::$server->getConfig()->getAppValue($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->getConfig()->setAppValue($app, 'enabled', 'yes');
} }
} }
} }
@ -1075,7 +1075,7 @@ class OC_App {
self::setAppTypes($appId); self::setAppTypes($appId);
$version = \OC_App::getAppVersion($appId); $version = \OC_App::getAppVersion($appId);
\OC::$server->getAppConfig()->setValue($appId, 'installed_version', $version); \OC::$server->getConfig()->setAppValue($appId, 'installed_version', $version);
\OC::$server->getEventDispatcher()->dispatch(ManagerEvent::EVENT_APP_UPDATE, new ManagerEvent( \OC::$server->getEventDispatcher()->dispatch(ManagerEvent::EVENT_APP_UPDATE, new ManagerEvent(
ManagerEvent::EVENT_APP_UPDATE, $appId ManagerEvent::EVENT_APP_UPDATE, $appId

View file

@ -59,19 +59,6 @@ interface IAppConfig {
*/ */
public function getFilteredValues($app); public function getFilteredValues($app);
/**
* sets a value in the appconfig
* @param string $app app
* @param string $key key
* @param string|float|int $value value
* @deprecated 8.0.0 use method setAppValue of \OCP\IConfig
*
* Sets a value. If the key did not exist before it will be created.
* @return void
* @since 7.0.0
*/
public function setValue($app, $key, $value);
/** /**
* Get all apps using the config * Get all apps using the config
* @return array an array of app ids * @return array an array of app ids

View file

@ -71,7 +71,7 @@ if($username) {
if($quota === 'default') {//'default' as default quota makes no sense if($quota === 'default') {//'default' as default quota makes no sense
$quota='none'; $quota='none';
} }
\OC::$server->getAppConfig()->setValue('files', 'default_quota', $quota); \OC::$server->getConfig()->setAppValue('files', 'default_quota', $quota);
} }
OC_JSON::success(array("data" => array( "username" => $username , 'quota' => $quota))); OC_JSON::success(array("data" => array( "username" => $username , 'quota' => $quota)));

View file

@ -104,7 +104,7 @@ class ShareTest extends \Test\TestCase {
\OC_Hook::clear('OCP\\Share'); \OC_Hook::clear('OCP\\Share');
\OC::registerShareHooks(); \OC::registerShareHooks();
$this->resharing = \OC::$server->getConfig()->getAppValue('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->getConfig()->setAppValue('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.
$now = time(); $now = time();
@ -116,7 +116,7 @@ class ShareTest extends \Test\TestCase {
protected function tearDown() { protected function tearDown() {
$query = \OC_DB::prepare('DELETE FROM `*PREFIX*share` WHERE `item_type` = ?'); $query = \OC_DB::prepare('DELETE FROM `*PREFIX*share` WHERE `item_type` = ?');
$query->execute(array('test')); $query->execute(array('test'));
\OC::$server->getAppConfig()->setValue('core', 'shareapi_allow_resharing', $this->resharing); \OC::$server->getConfig()->setAppValue('core', 'shareapi_allow_resharing', $this->resharing);
$this->user1->delete(); $this->user1->delete();
$this->user2->delete(); $this->user2->delete();