Skip to content

Commit 644cf2f

Browse files
Merge pull request #63641 from nextcloud/backport/63450/stable32
[stable32] fix(appconfig): make type-conflict error self-explanatory
2 parents 9832bdd + de87cb4 commit 644cf2f

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

lib/private/AppConfig.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -526,8 +526,15 @@ private function getTypedValue(
526526
&& $knownType > 0
527527
&& !$this->isTyped(self::VALUE_MIXED, $knownType)
528528
&& !$this->isTyped($type, $knownType)) {
529-
$this->logger->warning('conflict with value type from database', ['app' => $app, 'key' => $key, 'type' => $type, 'knownType' => $knownType]);
530-
throw new AppConfigTypeConflictException('conflict with value type from database');
529+
$requestedType = $storedType = null;
530+
try {
531+
$requestedType = $this->convertTypeToString($type);
532+
$storedType = $this->convertTypeToString($knownType);
533+
} catch (AppConfigIncorrectTypeException) {
534+
// can be ignored, this was just needed for a better exception message.
535+
}
536+
$this->logger->warning('Config value {app}/{key} is stored as {storedType} but was requested as {requestedType}', ['app' => $app, 'key' => $key, 'storedType' => $storedType ?? $knownType, 'requestedType' => $requestedType ?? $type]);
537+
throw new AppConfigTypeConflictException('Config value ' . $app . '/' . $key . ' is stored as ' . ($storedType ?? (string)$knownType) . ' but was requested as ' . ($requestedType ?? (string)$type));
531538
}
532539

533540
/**

0 commit comments

Comments
 (0)