aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2024-10-20 21:04:14 +0200
committerJoas Schilling <coding@schilljs.com>2024-11-06 14:16:10 +0100
commitf237846e74b838ea7d1e1d4cd0109447223b8e26 (patch)
tree57df91942b2646896f5a543bd1e7182b20d3c062 /lib/private
parent9276f453ae7046ae42a97415378af813f4e718b0 (diff)
downloadnextcloud-server-f237846e74b838ea7d1e1d4cd0109447223b8e26.tar.gz
nextcloud-server-f237846e74b838ea7d1e1d4cd0109447223b8e26.zip
feat(appconfig): Only log lazy-appconfig when an app can do something about ittechdebt/noid/more-useful-debug-logs
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib/private')
-rw-r--r--lib/private/AppConfig.php34
1 files changed, 18 insertions, 16 deletions
diff --git a/lib/private/AppConfig.php b/lib/private/AppConfig.php
index a0e5d7e28e8..dc9bac7745d 100644
--- a/lib/private/AppConfig.php
+++ b/lib/private/AppConfig.php
@@ -97,7 +97,7 @@ class AppConfig implements IAppConfig {
*/
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 @@ class AppConfig implements IAppConfig {
*/
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 @@ class AppConfig implements IAppConfig {
*/
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 @@ class AppConfig implements IAppConfig {
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 @@ class AppConfig implements IAppConfig {
*/
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<array-key, array<array-key, mixed>> $cache */
if ($lazy) {
@@ -430,7 +430,7 @@ class AppConfig implements IAppConfig {
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 @@ class AppConfig implements IAppConfig {
*/
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 @@ class AppConfig implements IAppConfig {
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 @@ class AppConfig implements IAppConfig {
}
}
- private function loadConfigAll(): void {
- $this->loadConfig(null);
+ private function loadConfigAll(?string $app = null): void {
+ $this->loadConfig($app, null);
}
/**
@@ -1185,20 +1185,22 @@ class AppConfig implements IAppConfig {
*
* @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) {
+ $exception = new \RuntimeException('The loading of lazy AppConfig values have been triggered by app "' . $app . '"');
+ $this->logger->debug($exception->getMessage(), ['exception' => $exception, 'app' => $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) {
@@ -1227,7 +1229,7 @@ class AppConfig implements IAppConfig {
}
$this->migrationCompleted = false;
- $this->loadConfig($lazy);
+ $this->loadConfig($app, $lazy);
return;
}
@@ -1301,7 +1303,7 @@ class AppConfig implements IAppConfig {
* 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;
}