diff --git a/lib/private/AppConfig.php b/lib/private/AppConfig.php index a78baee859a..50fa23e516e 100644 --- a/lib/private/AppConfig.php +++ b/lib/private/AppConfig.php @@ -69,6 +69,8 @@ class AppConfig implements IAppConfig { /** @var array, aliases: array, strictness: Strictness}> ['app_id' => ['strictness' => ConfigLexiconStrictness, 'entries' => ['config_key' => ConfigLexiconEntry[]]] */ private array $configLexiconDetails = []; private bool $ignoreLexiconAliases = false; + private array $strictnessApplied = []; + /** @var ?array */ private ?array $appVersionsCache = null; private ?ICache $localCache = null; @@ -1698,7 +1700,7 @@ class AppConfig implements IAppConfig { } 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 @@ -1743,22 +1745,26 @@ class AppConfig implements IAppConfig { * @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; } diff --git a/lib/private/Config/UserConfig.php b/lib/private/Config/UserConfig.php index 3a78d91ee76..d0d19561e2d 100644 --- a/lib/private/Config/UserConfig.php +++ b/lib/private/Config/UserConfig.php @@ -66,6 +66,7 @@ class UserConfig implements IUserConfig { /** @var array, aliases: array, 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, @@ -1903,7 +1904,7 @@ class UserConfig implements IUserConfig { } 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 @@ -1970,21 +1971,28 @@ class UserConfig implements IUserConfig { * * @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);