Skip to content

Commit d63f799

Browse files
icewind1991backportbot[bot]
authored andcommitted
fix: throw better error message if a user doesn't have a key even though it should have
fix: throw better error message if a user doesn't have a key even though it should have Signed-off-by: Robin Appelman <robin@icewind.nl> [skip ci]
1 parent 061a991 commit d63f799

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

lib/private/Config/UserConfig.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1142,6 +1142,8 @@ private function setTypedValue(
11421142
}
11431143

11441144
if ($this->hasKey($userId, $app, $key, $lazy)) {
1145+
$updateReason = 'key exists';
1146+
11451147
/**
11461148
* no update if key is already known with set lazy status and value is
11471149
* not different, unless sensitivity is switched from false to true.
@@ -1175,6 +1177,7 @@ private function setTypedValue(
11751177
// TODO: throw exception or just log and returns false !?
11761178
throw $e;
11771179
}
1180+
$updateReason = 'insert raised a duplicate contraint';
11781181
}
11791182
}
11801183

@@ -1185,7 +1188,11 @@ private function setTypedValue(
11851188
$currType = $this->valueDetails[$userId][$app][$key]['type'] ?? null;
11861189
if ($currType === null) { // this might happen when switching lazy loading status
11871190
$this->loadConfigAll($userId);
1188-
$currType = $this->valueDetails[$userId][$app][$key]['type'];
1191+
1192+
if (!isset($this->valueDetails[$userId][$app][$key])) {
1193+
throw new UnknownKeyException("unknown key $app $key for $userId even though $updateReason");
1194+
}
1195+
$currType = $this->valueDetails[$userId][$app][$key]['type'] ?? null;
11891196
}
11901197

11911198
/**

0 commit comments

Comments
 (0)