Skip to content
Closed
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
12 changes: 12 additions & 0 deletions core/Command/Config/App/SetConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ protected function configure() {
InputOption::VALUE_NEGATABLE,
'Set value as sensitive',
)
->addOption(
'internal',
null,
InputOption::VALUE_NONE,
'Confirm the edit of an internal value',
)
->addOption(
'update-only',
null,
Expand Down Expand Up @@ -159,6 +165,12 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$sensitive = $sensitive ?? false;
}

if (!$input->getOption('internal') && ($this->appConfig->getKeyDetails($appName, $configName)['internal'] ?? false)) {
$output->writeln('<error>Config key is set as INTERNAL and modifying it might induce strange behavior or break user experience.</error>');
$output->writeln('please use option <comment>--internal</comment> to confirm your action');
return self::FAILURE;
}

$value = (string)$input->getOption('value');
switch ($type) {
case IAppConfig::VALUE_MIXED:
Expand Down
3 changes: 2 additions & 1 deletion lib/private/AppConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -1115,7 +1115,7 @@ public function getDetails(string $app, string $key): array {
* @param string $app id of the app
* @param string $key config key
*
* @return array{app: string, key: string, lazy?: bool, valueType?: ValueType, valueTypeName?: string, sensitive?: bool, default?: string, definition?: string, note?: string}
* @return array{app: string, key: string, lazy?: bool, valueType?: ValueType, valueTypeName?: string, sensitive?: bool, internal?: bool, default?: string, definition?: string, note?: string}
* @since 32.0.0
*/
public function getKeyDetails(string $app, string $key): array {
Expand Down Expand Up @@ -1143,6 +1143,7 @@ public function getKeyDetails(string $app, string $key): array {
'valueType' => $lexiconEntry->getValueType(),
'valueTypeName' => $lexiconEntry->getValueType()->name,
'sensitive' => $lexiconEntry->isFlagged(self::FLAG_SENSITIVE),
'internal' => $lexiconEntry->isFlagged(self::FLAG_INTERNAL),
'default' => $lexiconEntry->getDefault($this->presetManager->getLexiconPreset()),
'definition' => $lexiconEntry->getDefinition(),
'note' => $lexiconEntry->getNote(),
Expand Down
4 changes: 4 additions & 0 deletions lib/public/Config/IUserConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ interface IUserConfig {
* @since 32.0.0
*/
public const FLAG_INDEXED = 2; // value should be indexed
/**
* @since 33.0.0
*/
public const FLAG_INTERNAL = 4; // value is considered internal and can be hidden from listing

/**
* Get list of all userIds with config stored in database.
Expand Down
6 changes: 5 additions & 1 deletion lib/public/IAppConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ interface IAppConfig {

/** @since 31.0.0 */
public const FLAG_SENSITIVE = 1; // value is sensitive
/**
* @since 33.0.0
*/
public const FLAG_INTERNAL = 4; // value is considered internal and can be hidden from listing

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