Skip to content

Commit 41ebeb6

Browse files
icewind1991CarlSchwan
authored andcommitted
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> Signed-off-by: Carl Schwan <carl@carlschwan.eu>
1 parent 061a991 commit 41ebeb6

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

lib/private/Config/UserConfig.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1141,7 +1141,10 @@ private function setTypedValue(
11411141
}
11421142
}
11431143

1144+
$updateReason = '';
11441145
if ($this->hasKey($userId, $app, $key, $lazy)) {
1146+
$updateReason = 'key exists';
1147+
11451148
/**
11461149
* no update if key is already known with set lazy status and value is
11471150
* not different, unless sensitivity is switched from false to true.
@@ -1175,6 +1178,7 @@ private function setTypedValue(
11751178
// TODO: throw exception or just log and returns false !?
11761179
throw $e;
11771180
}
1181+
$updateReason = 'insert raised a duplicate contraint';
11781182
}
11791183
}
11801184

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

11911199
/**

0 commit comments

Comments
 (0)