Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions core/Command/Config/App/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@
*/
namespace OC\Core\Command\Config\App;

use OC\Config\ConfigManager;
use OCP\IAppConfig;
use Stecman\Component\Symfony\Console\BashCompletion\CompletionContext;

abstract class Base extends \OC\Core\Command\Base {
public function __construct(
protected IAppConfig $appConfig,
protected readonly ConfigManager $configManager,
) {
parent::__construct();
}
Expand Down
25 changes: 4 additions & 21 deletions core/Command/Config/App/SetConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
namespace OC\Core\Command\Config\App;

use OC\AppConfig;
use OCP\Exceptions\AppConfigIncorrectTypeException;
use OCP\Exceptions\AppConfigUnknownKeyException;
use OCP\IAppConfig;
use Symfony\Component\Console\Helper\QuestionHelper;
Expand Down Expand Up @@ -161,7 +160,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int
}

$value = (string)$input->getOption('value');

switch ($type) {
case IAppConfig::VALUE_MIXED:
$updated = $this->appConfig->setValueMixed($appName, $configName, $value, $lazy, $sensitive);
Expand All @@ -172,34 +170,19 @@ protected function execute(InputInterface $input, OutputInterface $output): int
break;

case IAppConfig::VALUE_INT:
if ($value !== ((string)((int)$value))) {
throw new AppConfigIncorrectTypeException('Value is not an integer');
}
$updated = $this->appConfig->setValueInt($appName, $configName, (int)$value, $lazy, $sensitive);
$updated = $this->appConfig->setValueInt($appName, $configName, $this->configManager->convertToInt($value), $lazy, $sensitive);
break;

case IAppConfig::VALUE_FLOAT:
if ($value !== ((string)((float)$value))) {
throw new AppConfigIncorrectTypeException('Value is not a float');
}
$updated = $this->appConfig->setValueFloat($appName, $configName, (float)$value, $lazy, $sensitive);
$updated = $this->appConfig->setValueFloat($appName, $configName, $this->configManager->convertToFloat($value), $lazy, $sensitive);
break;

case IAppConfig::VALUE_BOOL:
if (in_array(strtolower($value), ['true', '1', 'on', 'yes'])) {
$valueBool = true;
} elseif (in_array(strtolower($value), ['false', '0', 'off', 'no'])) {
$valueBool = false;
} else {
throw new AppConfigIncorrectTypeException('Value is not a boolean, please use \'true\' or \'false\'');
}
$updated = $this->appConfig->setValueBool($appName, $configName, $valueBool, $lazy);
$updated = $this->appConfig->setValueBool($appName, $configName, $this->configManager->convertToBool($value), $lazy);
break;

case IAppConfig::VALUE_ARRAY:
$valueArray = json_decode($value, true, flags: JSON_THROW_ON_ERROR);
$valueArray = (is_array($valueArray)) ? $valueArray : throw new AppConfigIncorrectTypeException('Value is not an array');
$updated = $this->appConfig->setValueArray($appName, $configName, $valueArray, $lazy, $sensitive);
$updated = $this->appConfig->setValueArray($appName, $configName, $this->configManager->convertToArray($value), $lazy, $sensitive);
break;
}
}
Expand Down
7 changes: 7 additions & 0 deletions core/Command/Config/ListConfigs.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*/
namespace OC\Core\Command\Config;

use OC\Config\ConfigManager;
use OC\Core\Command\Base;
use OC\SystemConfig;
use OCP\IAppConfig;
Expand All @@ -22,6 +23,7 @@ class ListConfigs extends Base {
public function __construct(
protected SystemConfig $systemConfig,
protected IAppConfig $appConfig,
protected ConfigManager $configManager,
) {
parent::__construct();
}
Expand All @@ -44,13 +46,18 @@ protected function configure() {
InputOption::VALUE_NONE,
'Use this option when you want to include sensitive configs like passwords, salts, ...'
)
->addOption('migrate', null, InputOption::VALUE_NONE, 'Rename config keys of all enabled apps, based on ConfigLexicon')
;
}

protected function execute(InputInterface $input, OutputInterface $output): int {
$app = $input->getArgument('app');
$noSensitiveValues = !$input->getOption('private');

if ($input->getOption('migrate')) {
$this->configManager->migrateConfigLexiconKeys(($app === 'all') ? null : $app);
}

if (!is_string($app)) {
$output->writeln('<error>Invalid app value given</error>');
return 1;
Expand Down
2 changes: 2 additions & 0 deletions lib/composer/composer/autoload_classmap.php
Original file line number Diff line number Diff line change
Expand Up @@ -1190,6 +1190,7 @@
'OC\\Comments\\Manager' => $baseDir . '/lib/private/Comments/Manager.php',
'OC\\Comments\\ManagerFactory' => $baseDir . '/lib/private/Comments/ManagerFactory.php',
'OC\\Config' => $baseDir . '/lib/private/Config.php',
'OC\\Config\\ConfigManager' => $baseDir . '/lib/private/Config/ConfigManager.php',
'OC\\Config\\Lexicon\\CoreConfigLexicon' => $baseDir . '/lib/private/Config/Lexicon/CoreConfigLexicon.php',
'OC\\Config\\UserConfig' => $baseDir . '/lib/private/Config/UserConfig.php',
'OC\\Console\\Application' => $baseDir . '/lib/private/Console/Application.php',
Expand Down Expand Up @@ -1901,6 +1902,7 @@
'OC\\Repair\\ClearGeneratedAvatarCache' => $baseDir . '/lib/private/Repair/ClearGeneratedAvatarCache.php',
'OC\\Repair\\ClearGeneratedAvatarCacheJob' => $baseDir . '/lib/private/Repair/ClearGeneratedAvatarCacheJob.php',
'OC\\Repair\\Collation' => $baseDir . '/lib/private/Repair/Collation.php',
'OC\\Repair\\ConfigKeyMigration' => $baseDir . '/lib/private/Repair/ConfigKeyMigration.php',
'OC\\Repair\\Events\\RepairAdvanceEvent' => $baseDir . '/lib/private/Repair/Events/RepairAdvanceEvent.php',
'OC\\Repair\\Events\\RepairErrorEvent' => $baseDir . '/lib/private/Repair/Events/RepairErrorEvent.php',
'OC\\Repair\\Events\\RepairFinishEvent' => $baseDir . '/lib/private/Repair/Events/RepairFinishEvent.php',
Expand Down
2 changes: 2 additions & 0 deletions lib/composer/composer/autoload_static.php
Original file line number Diff line number Diff line change
Expand Up @@ -1231,6 +1231,7 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2
'OC\\Comments\\Manager' => __DIR__ . '/../../..' . '/lib/private/Comments/Manager.php',
'OC\\Comments\\ManagerFactory' => __DIR__ . '/../../..' . '/lib/private/Comments/ManagerFactory.php',
'OC\\Config' => __DIR__ . '/../../..' . '/lib/private/Config.php',
'OC\\Config\\ConfigManager' => __DIR__ . '/../../..' . '/lib/private/Config/ConfigManager.php',
'OC\\Config\\Lexicon\\CoreConfigLexicon' => __DIR__ . '/../../..' . '/lib/private/Config/Lexicon/CoreConfigLexicon.php',
'OC\\Config\\UserConfig' => __DIR__ . '/../../..' . '/lib/private/Config/UserConfig.php',
'OC\\Console\\Application' => __DIR__ . '/../../..' . '/lib/private/Console/Application.php',
Expand Down Expand Up @@ -1942,6 +1943,7 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2
'OC\\Repair\\ClearGeneratedAvatarCache' => __DIR__ . '/../../..' . '/lib/private/Repair/ClearGeneratedAvatarCache.php',
'OC\\Repair\\ClearGeneratedAvatarCacheJob' => __DIR__ . '/../../..' . '/lib/private/Repair/ClearGeneratedAvatarCacheJob.php',
'OC\\Repair\\Collation' => __DIR__ . '/../../..' . '/lib/private/Repair/Collation.php',
'OC\\Repair\\ConfigKeyMigration' => __DIR__ . '/../../..' . '/lib/private/Repair/ConfigKeyMigration.php',
'OC\\Repair\\Events\\RepairAdvanceEvent' => __DIR__ . '/../../..' . '/lib/private/Repair/Events/RepairAdvanceEvent.php',
'OC\\Repair\\Events\\RepairErrorEvent' => __DIR__ . '/../../..' . '/lib/private/Repair/Events/RepairErrorEvent.php',
'OC\\Repair\\Events\\RepairFinishEvent' => __DIR__ . '/../../..' . '/lib/private/Repair/Events/RepairFinishEvent.php',
Expand Down
15 changes: 11 additions & 4 deletions lib/private/App/AppManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

use OC\AppConfig;
use OC\AppFramework\Bootstrap\Coordinator;
use OC\Config\ConfigManager;
use OCP\Activity\IManager as IActivityManager;
use OCP\App\AppPathNotFoundException;
use OCP\App\Events\AppDisableEvent;
Expand All @@ -27,6 +28,7 @@
use OCP\IURLGenerator;
use OCP\IUser;
use OCP\IUserSession;
use OCP\Server;
use OCP\ServerVersion;
use OCP\Settings\IManager as ISettingsManager;
use Psr\Log\LoggerInterface;
Expand Down Expand Up @@ -82,12 +84,13 @@ public function __construct(
private IEventDispatcher $dispatcher,
private LoggerInterface $logger,
private ServerVersion $serverVersion,
private ConfigManager $configManager,
) {
}

private function getNavigationManager(): INavigationManager {
if ($this->navigationManager === null) {
$this->navigationManager = \OCP\Server::get(INavigationManager::class);
$this->navigationManager = Server::get(INavigationManager::class);
}
return $this->navigationManager;
}
Expand All @@ -113,7 +116,7 @@ private function getAppConfig(): AppConfig {
if (!$this->config->getSystemValueBool('installed', false)) {
throw new \Exception('Nextcloud is not installed yet, AppConfig is not available');
}
$this->appConfig = \OCP\Server::get(AppConfig::class);
$this->appConfig = Server::get(AppConfig::class);
return $this->appConfig;
}

Expand All @@ -124,7 +127,7 @@ private function getUrlGenerator(): IURLGenerator {
if (!$this->config->getSystemValueBool('installed', false)) {
throw new \Exception('Nextcloud is not installed yet, AppConfig is not available');
}
$this->urlGenerator = \OCP\Server::get(IURLGenerator::class);
$this->urlGenerator = Server::get(IURLGenerator::class);
return $this->urlGenerator;
}

Expand Down Expand Up @@ -459,7 +462,7 @@ public function loadApp(string $app): void {
]);
}

$coordinator = \OCP\Server::get(Coordinator::class);
$coordinator = Server::get(Coordinator::class);
$coordinator->bootApp($app);

$eventLogger->start("bootstrap:load_app:$app:info", "Load info.xml for $app and register any services defined in it");
Expand Down Expand Up @@ -568,6 +571,8 @@ public function enableApp(string $appId, bool $forceEnable = false): void {
ManagerEvent::EVENT_APP_ENABLE, $appId
));
$this->clearAppsCache();

$this->configManager->migrateConfigLexiconKeys($appId);
}

/**
Expand Down Expand Up @@ -626,6 +631,8 @@ public function enableAppForGroups(string $appId, array $groups, bool $forceEnab
ManagerEvent::EVENT_APP_ENABLE_FOR_GROUPS, $appId, $groups
));
$this->clearAppsCache();

$this->configManager->migrateConfigLexiconKeys($appId);
}

/**
Expand Down
Loading
Loading