diff --git a/lib/private/AppConfig.php b/lib/private/AppConfig.php index b1fde7c4965d8..858264eaf74c2 100644 --- a/lib/private/AppConfig.php +++ b/lib/private/AppConfig.php @@ -97,7 +97,7 @@ public function getApps(): array { */ public function getKeys(string $app): array { $this->assertParams($app); - $this->loadConfigAll(); + $this->loadConfigAll($app); $keys = array_merge(array_keys($this->fastCache[$app] ?? []), array_keys($this->lazyCache[$app] ?? [])); sort($keys); @@ -117,7 +117,7 @@ public function getKeys(string $app): array { */ public function hasKey(string $app, string $key, ?bool $lazy = false): bool { $this->assertParams($app, $key); - $this->loadConfig($lazy); + $this->loadConfig($app, $lazy); if ($lazy === null) { $appCache = $this->getAllValues($app); @@ -142,7 +142,7 @@ public function hasKey(string $app, string $key, ?bool $lazy = false): bool { */ public function isSensitive(string $app, string $key, ?bool $lazy = false): bool { $this->assertParams($app, $key); - $this->loadConfig($lazy); + $this->loadConfig(null, $lazy); if (!isset($this->valueTypes[$app][$key])) { throw new AppConfigUnknownKeyException('unknown config key'); @@ -190,7 +190,7 @@ public function isLazy(string $app, string $key): bool { public function getAllValues(string $app, string $prefix = '', bool $filtered = false): array { $this->assertParams($app, $prefix); // if we want to filter values, we need to get sensitivity - $this->loadConfigAll(); + $this->loadConfigAll($app); // array_merge() will remove numeric keys (here config keys), so addition arrays instead $values = $this->formatAppValues($app, ($this->fastCache[$app] ?? []) + ($this->lazyCache[$app] ?? [])); $values = array_filter( @@ -234,7 +234,7 @@ function (string $key) use ($prefix): bool { */ public function searchValues(string $key, bool $lazy = false, ?int $typedAs = null): array { $this->assertParams('', $key, true); - $this->loadConfig($lazy); + $this->loadConfig(null, $lazy); /** @var array> $cache */ if ($lazy) { @@ -430,7 +430,7 @@ private function getTypedValue( int $type, ): string { $this->assertParams($app, $key, valueType: $type); - $this->loadConfig($lazy); + $this->loadConfig($app, $lazy); /** * We ignore check if mixed type is requested. @@ -487,7 +487,7 @@ private function getTypedValue( */ public function getValueType(string $app, string $key, ?bool $lazy = null): int { $this->assertParams($app, $key); - $this->loadConfig($lazy); + $this->loadConfig($app, $lazy); if (!isset($this->valueTypes[$app][$key])) { throw new AppConfigUnknownKeyException('unknown config key'); @@ -721,7 +721,7 @@ private function setTypedValue( int $type, ): bool { $this->assertParams($app, $key); - $this->loadConfig($lazy); + $this->loadConfig(null, $lazy); $sensitive = $this->isTyped(self::VALUE_SENSITIVE, $type); $inserted = $refreshCache = false; @@ -1176,8 +1176,8 @@ private function assertParams(string $app = '', string $configKey = '', bool $al } } - private function loadConfigAll(): void { - $this->loadConfig(null); + private function loadConfigAll(?string $app = null): void { + $this->loadConfig($app, null); } /** @@ -1185,20 +1185,21 @@ private function loadConfigAll(): void { * * @param bool|null $lazy set to TRUE to load config set as lazy loaded, set to NULL to load all config */ - private function loadConfig(?bool $lazy = false): void { + private function loadConfig(?string $app = null, ?bool $lazy = false): void { if ($this->isLoaded($lazy)) { return; } - if (($lazy ?? true) !== false) { // if lazy is null or true, we debug log - $this->logger->debug('The loading of lazy AppConfig values have been requested', ['exception' => new \RuntimeException('ignorable exception')]); + // if lazy is null or true, we debug log + if (($lazy ?? true) !== false && $app !== null) { + $this->logger->debug('The loading of lazy AppConfig values have been triggered by app "' . $app . '"', ['exception' => new \RuntimeException($app)]); } $qb = $this->connection->getQueryBuilder(); $qb->from('appconfig'); /** - * The use of $this->>migrationCompleted is only needed to manage the + * The use of $this->migrationCompleted is only needed to manage the * database during the upgrading process to nc29. */ if (!$this->migrationCompleted) { @@ -1301,7 +1302,7 @@ private function setAsLoaded(?bool $lazy): void { * not exist the default value will be returned */ public function getValue($app, $key, $default = null) { - $this->loadConfig(); + $this->loadConfig($app); return $this->fastCache[$app][$key] ?? $default; }