Skip to content

Commit 4a399a3

Browse files
Merge pull request #56159 from nextcloud/feat/noid/lexicon-internal-flag
feat(lexicon): add FLAG_INTERNAL
2 parents 69ec2ce + 1538692 commit 4a399a3

File tree

4 files changed

+23
-2
lines changed

4 files changed

+23
-2
lines changed

core/Command/Config/App/SetConfig.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,12 @@ protected function configure() {
6060
InputOption::VALUE_NEGATABLE,
6161
'Set value as sensitive',
6262
)
63+
->addOption(
64+
'internal',
65+
null,
66+
InputOption::VALUE_NONE,
67+
'Confirm the edit of an internal value',
68+
)
6369
->addOption(
6470
'update-only',
6571
null,
@@ -159,6 +165,12 @@ protected function execute(InputInterface $input, OutputInterface $output): int
159165
$sensitive = $sensitive ?? false;
160166
}
161167

168+
if (!$input->getOption('internal') && ($this->appConfig->getKeyDetails($appName, $configName)['internal'] ?? false)) {
169+
$output->writeln('<error>Config key is set as INTERNAL and modifying it might induce strange behavior or break user experience.</error>');
170+
$output->writeln('please use option <comment>--internal</comment> to confirm your action');
171+
return self::FAILURE;
172+
}
173+
162174
$value = (string)$input->getOption('value');
163175
switch ($type) {
164176
case IAppConfig::VALUE_MIXED:

lib/private/AppConfig.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1115,7 +1115,7 @@ public function getDetails(string $app, string $key): array {
11151115
* @param string $app id of the app
11161116
* @param string $key config key
11171117
*
1118-
* @return array{app: string, key: string, lazy?: bool, valueType?: ValueType, valueTypeName?: string, sensitive?: bool, default?: string, definition?: string, note?: string}
1118+
* @return array{app: string, key: string, lazy?: bool, valueType?: ValueType, valueTypeName?: string, sensitive?: bool, internal?: bool, default?: string, definition?: string, note?: string}
11191119
* @since 32.0.0
11201120
*/
11211121
public function getKeyDetails(string $app, string $key): array {
@@ -1143,6 +1143,7 @@ public function getKeyDetails(string $app, string $key): array {
11431143
'valueType' => $lexiconEntry->getValueType(),
11441144
'valueTypeName' => $lexiconEntry->getValueType()->name,
11451145
'sensitive' => $lexiconEntry->isFlagged(self::FLAG_SENSITIVE),
1146+
'internal' => $lexiconEntry->isFlagged(self::FLAG_INTERNAL),
11461147
'default' => $lexiconEntry->getDefault($this->presetManager->getLexiconPreset()),
11471148
'definition' => $lexiconEntry->getDefinition(),
11481149
'note' => $lexiconEntry->getNote(),

lib/public/Config/IUserConfig.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ interface IUserConfig {
3838
* @since 32.0.0
3939
*/
4040
public const FLAG_INDEXED = 2; // value should be indexed
41+
/**
42+
* @since 33.0.0
43+
*/
44+
public const FLAG_INTERNAL = 4; // value is considered internal and can be hidden from listing
4145

4246
/**
4347
* Get list of all userIds with config stored in database.

lib/public/IAppConfig.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ interface IAppConfig {
4848

4949
/** @since 31.0.0 */
5050
public const FLAG_SENSITIVE = 1; // value is sensitive
51+
/**
52+
* @since 33.0.0
53+
*/
54+
public const FLAG_INTERNAL = 4; // value is considered internal and can be hidden from listing
5155

5256
/**
5357
* Get list of all apps that have at least one config value stored in database
@@ -472,7 +476,7 @@ public function getDetails(string $app, string $key): array;
472476
* @param string $app id of the app
473477
* @param string $key config key
474478
*
475-
* @return array{app: string, key: string, lazy?: bool, valueType?: ValueType, valueTypeName?: string, sensitive?: bool, default?: string, definition?: string, note?: string}
479+
* @return array{app: string, key: string, lazy?: bool, valueType?: ValueType, valueTypeName?: string, sensitive?: bool, internal?: bool, default?: string, definition?: string, note?: string}
476480
* @since 32.0.0
477481
*/
478482
public function getKeyDetails(string $app, string $key): array;

0 commit comments

Comments
 (0)