Skip to content
Draft
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
fix(lexicon): enforce type from lexicon
Signed-off-by: Maxence Lange <[email protected]>
  • Loading branch information
ArtificialOwl committed Nov 6, 2025
commit ac6a9be2ebe7ac48c2756904f46961c844a0da01
1 change: 1 addition & 0 deletions apps/dav/lib/ConfigLexicon.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public function getAppConfigs(): array {
defaultRaw: true,
definition: 'Whether to not expose the system address book to users',
lazy: true,
options: Entry::ENFORCE_VALUE_TYPE
),
];
}
Expand Down
12 changes: 9 additions & 3 deletions lib/private/AppConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,9 @@ private function getTypedValue(
): string {
$this->assertParams($app, $key, valueType: $type);
$origKey = $key;
$matched = $this->matchAndApplyLexiconDefinition($app, $key, $lazy, $type, $default);
/** @var ?Entry $lexiconEntry */
$lexiconEntry = null;
$matched = $this->matchAndApplyLexiconDefinition($app, $key, $lazy, $type, $default, $lexiconEntry);
if ($default === null) {
// there is no logical reason for it to be null
throw new \Exception('default cannot be null');
Expand All @@ -501,8 +503,12 @@ private function getTypedValue(
&& $knownType > 0
&& !$this->isTyped(self::VALUE_MIXED, $knownType)
&& !$this->isTyped($type, $knownType)) {
$this->logger->warning('conflict with value type from database', ['app' => $app, 'key' => $key, 'type' => $type, 'knownType' => $knownType]);
throw new AppConfigTypeConflictException('conflict with value type from database');
if ($lexiconEntry?->hasOption(Entry::ENFORCE_VALUE_TYPE)) {
$this->updateType($app, $key, $lexiconEntry->getValueType()->toAppConfigFlag());
} else {
$this->logger->warning('conflict with value type from database', ['app' => $app, 'key' => $key, 'type' => $type, 'knownType' => $knownType]);
throw new AppConfigTypeConflictException('conflict with value type from database');
}
}

/**
Expand Down
3 changes: 2 additions & 1 deletion lib/public/Config/Lexicon/Entry.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
class Entry {
/** @since 32.0.0 */
public const RENAME_INVERT_BOOLEAN = 1;

/** @since 32.0.0 */
public const ENFORCE_VALUE_TYPE = 2;
private ?string $default = null;

/**
Expand Down
Loading