Skip to content

Commit c34e252

Browse files
authored
Merge pull request #44276 from nextcloud/fix/config/string-user-keys
2 parents daf7252 + b8868e2 commit c34e252

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

lib/private/AllConfig.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ public function getUserValue($userId, $appName, $key, $default = '') {
339339
public function getUserKeys($userId, $appName) {
340340
$data = $this->getAllUserValues($userId);
341341
if (isset($data[$appName])) {
342-
return array_keys($data[$appName]);
342+
return array_map('strval', array_keys($data[$appName]));
343343
} else {
344344
return [];
345345
}

tests/lib/AllConfigTest.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,31 @@ public function testGetUserKeys() {
277277
$this->connection->executeUpdate('DELETE FROM `*PREFIX*preferences`');
278278
}
279279

280+
public function testGetUserKeysAllInts() {
281+
$config = $this->getConfig();
282+
283+
// preparation - add something to the database
284+
$data = [
285+
['userFetch', 'appFetch1', '123', 'value'],
286+
['userFetch', 'appFetch1', '456', 'value'],
287+
];
288+
foreach ($data as $entry) {
289+
$this->connection->executeUpdate(
290+
'INSERT INTO `*PREFIX*preferences` (`userid`, `appid`, ' .
291+
'`configkey`, `configvalue`) VALUES (?, ?, ?, ?)',
292+
$entry
293+
);
294+
}
295+
296+
$value = $config->getUserKeys('userFetch', 'appFetch1');
297+
$this->assertEquals(['123', '456'], $value);
298+
$this->assertIsString($value[0]);
299+
$this->assertIsString($value[1]);
300+
301+
// cleanup
302+
$this->connection->executeUpdate('DELETE FROM `*PREFIX*preferences`');
303+
}
304+
280305
public function testGetUserValueDefault() {
281306
$config = $this->getConfig();
282307

0 commit comments

Comments
 (0)