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
20 changes: 13 additions & 7 deletions lib/private/AppConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ class AppConfig implements IAppConfig {
/** @var array<string, array{entries: array<string, Entry>, aliases: array<string, string>, strictness: Strictness}> ['app_id' => ['strictness' => ConfigLexiconStrictness, 'entries' => ['config_key' => ConfigLexiconEntry[]]] */
private array $configLexiconDetails = [];
private bool $ignoreLexiconAliases = false;
private array $strictnessApplied = [];

/** @var ?array<string, string> */
private ?array $appVersionsCache = null;
private ?ICache $localCache = null;
Expand Down Expand Up @@ -1698,7 +1700,7 @@ private function matchAndApplyLexiconDefinition(
}

if (!array_key_exists($key, $configDetails['entries'])) {
return $this->applyLexiconStrictness($configDetails['strictness'], 'The app config key ' . $app . '/' . $key . ' is not defined in the config lexicon');
return $this->applyLexiconStrictness($configDetails['strictness'], $app . '/' . $key);
}

// if lazy is NULL, we ignore all check on the type/lazyness/default from Lexicon
Expand Down Expand Up @@ -1743,22 +1745,26 @@ private function matchAndApplyLexiconDefinition(
* @throws AppConfigUnknownKeyException if strictness implies exception
* @see \OCP\Config\Lexicon\ILexicon::getStrictness()
*/
private function applyLexiconStrictness(
?Strictness $strictness,
string $line = '',
): bool {
private function applyLexiconStrictness(?Strictness $strictness, string $configAppKey): bool {
if ($strictness === null) {
return true;
}

$line = 'The app config key ' . $configAppKey . ' is not defined in the config lexicon';
switch ($strictness) {
case Strictness::IGNORE:
return true;
case Strictness::NOTICE:
$this->logger->notice($line);
if (!in_array($configAppKey, $this->strictnessApplied, true)) {
$this->strictnessApplied[] = $configAppKey;
$this->logger->notice($line);
}
return true;
case Strictness::WARNING:
$this->logger->warning($line);
if (!in_array($configAppKey, $this->strictnessApplied, true)) {
$this->strictnessApplied[] = $configAppKey;
$this->logger->warning($line);
}
return false;
}

Expand Down
18 changes: 13 additions & 5 deletions lib/private/Config/UserConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ class UserConfig implements IUserConfig {
/** @var array<string, array{entries: array<string, Entry>, aliases: array<string, string>, strictness: Strictness}> ['app_id' => ['strictness' => ConfigLexiconStrictness, 'entries' => ['config_key' => ConfigLexiconEntry[]]] */
private array $configLexiconDetails = [];
private bool $ignoreLexiconAliases = false;
private array $strictnessApplied = [];

public function __construct(
protected IDBConnection $connection,
Expand Down Expand Up @@ -1903,7 +1904,7 @@ private function matchAndApplyLexiconDefinition(
}

if (!array_key_exists($key, $configDetails['entries'])) {
return $this->applyLexiconStrictness($configDetails['strictness'], 'The user config key ' . $app . '/' . $key . ' is not defined in the config lexicon');
return $this->applyLexiconStrictness($configDetails['strictness'], $app . '/' . $key);
}

// if lazy is NULL, we ignore all check on the type/lazyness/default from Lexicon
Expand Down Expand Up @@ -1970,21 +1971,28 @@ private function getSystemDefault(string $appId, Entry $configValue): ?string {
*
* @return bool TRUE if conflict can be fully ignored
* @throws UnknownKeyException
*@see ILexicon::getStrictness()
* @see ILexicon::getStrictness()
*/
private function applyLexiconStrictness(?Strictness $strictness, string $line = ''): bool {
private function applyLexiconStrictness(?Strictness $strictness, string $configAppKey): bool {
if ($strictness === null) {
return true;
}

$line = 'The user config key ' . $configAppKey . ' is not defined in the config lexicon';
switch ($strictness) {
case Strictness::IGNORE:
return true;
case Strictness::NOTICE:
$this->logger->notice($line);
if (!in_array($configAppKey, $this->strictnessApplied, true)) {
$this->strictnessApplied[] = $configAppKey;
$this->logger->notice($line);
}
return true;
case Strictness::WARNING:
$this->logger->warning($line);
if (!in_array($configAppKey, $this->strictnessApplied, true)) {
$this->strictnessApplied[] = $configAppKey;
$this->logger->warning($line);
}
return false;
case Strictness::EXCEPTION:
throw new UnknownKeyException($line);
Expand Down
Loading