Skip to content

Commit 93e4a55

Browse files
Merge pull request #63643 from nextcloud/backport/63450/stable34
[stable34] fix(appconfig): make type-conflict error self-explanatory
2 parents 7a14f23 + f50c043 commit 93e4a55

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
@@ -540,8 +540,15 @@ private function getTypedValue(
540540
&& $knownType > 0
541541
&& !$this->isTyped(self::VALUE_MIXED, $knownType)
542542
&& !$this->isTyped($type, $knownType)) {
543-
$this->logger->warning('conflict with value type from database', ['app' => $app, 'key' => $key, 'type' => $type, 'knownType' => $knownType]);
544-
throw new AppConfigTypeConflictException('conflict with value type from database');
543+
$requestedType = $storedType = null;
544+
try {
545+
$requestedType = $this->convertTypeToString($type);
546+
$storedType = $this->convertTypeToString($knownType);
547+
} catch (AppConfigIncorrectTypeException) {
548+
// can be ignored, this was just needed for a better exception message.
549+
}
550+
$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]);
551+
throw new AppConfigTypeConflictException('Config value ' . $app . '/' . $key . ' is stored as ' . ($storedType ?? (string)$knownType) . ' but was requested as ' . ($requestedType ?? (string)$type));
545552
}
546553

547554
/**

0 commit comments

Comments
 (0)