Skip to content
Open
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
2 changes: 1 addition & 1 deletion lib/private/AppConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ public function searchKeys(string $app, string $prefix = '', bool $lazy = false)
public function hasKey(string $app, string $key, ?bool $lazy = false): bool {
$this->assertParams($app, $key);
$this->loadConfig($app, $lazy ?? true);
$this->matchAndApplyLexiconDefinition($app, $key);
$this->matchAndApplyLexiconDefinition($app, $key, $lazy);

$hasLazy = isset($this->lazyCache[$app][$key]);
$hasFast = isset($this->fastCache[$app][$key]);
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 @@ -158,7 +158,12 @@ public function getKeys(string $userId, string $app): array {
public function hasKey(string $userId, string $app, string $key, ?bool $lazy = false): bool {
$this->assertParams($userId, $app, $key);
$this->loadConfig($userId, $lazy);
$this->matchAndApplyLexiconDefinition($userId, $app, $key);

// to avoid a loop on hasKey(), we set $default to null
// as matchAndApplyLexiconDefinition() will only search
// for $default if requested
$default = null;
$this->matchAndApplyLexiconDefinition($userId, $app, $key, $lazy, default: $default);

if ($lazy === null) {
$appCache = $this->getValues($userId, $app);
Expand Down Expand Up @@ -1970,15 +1975,18 @@ private function matchAndApplyLexiconDefinition(
}

$enforcedValue = $this->config->getSystemValue('lexicon.default.userconfig.enforced', [])[$app][$key] ?? false;
// only look for default if needed
if ($default === null) {
return !$enforcedValue;
}

if (!$enforcedValue && $this->hasKey($userId, $app, $key, $lazy)) {
// if key exists there should be no need to extract default
return true;
}

// only look for default if needed, default from Lexicon got priority if not overwritten by admin
if ($default !== null) {
$default = $this->getSystemDefault($app, $configValue) ?? $configValue->getDefault($this->presetManager->getLexiconPreset()) ?? $default;
}
// default from Lexicon got priority if not overwritten by admin
$default = $this->getSystemDefault($app, $configValue) ?? $configValue->getDefault($this->presetManager->getLexiconPreset()) ?? $default;

// returning false will make get() returning $default and set() not changing value in database
return !$enforcedValue;
Expand Down
Loading