Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fix(config): Make sure user keys are strings
Signed-off-by: Christoph Wurst <[email protected]>
  • Loading branch information
ChristophWurst authored and backportbot[bot] committed Mar 19, 2024
commit 3eb8082f0ce2ef62c1849d0949d74f45e3bba868
2 changes: 1 addition & 1 deletion lib/private/AllConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ public function getUserValue($userId, $appName, $key, $default = '') {
public function getUserKeys($userId, $appName) {
$data = $this->getAllUserValues($userId);
if (isset($data[$appName])) {
return array_keys($data[$appName]);
return array_map('strval', array_keys($data[$appName]));
} else {
return [];
}
Expand Down
25 changes: 25 additions & 0 deletions tests/lib/AllConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,31 @@ public function testGetUserKeys() {
$this->connection->executeUpdate('DELETE FROM `*PREFIX*preferences`');
}

public function testGetUserKeysAllInts() {
$config = $this->getConfig();

// preparation - add something to the database
$data = [
['userFetch', 'appFetch1', '123', 'value'],
['userFetch', 'appFetch1', '456', 'value'],
];
foreach ($data as $entry) {
$this->connection->executeUpdate(
'INSERT INTO `*PREFIX*preferences` (`userid`, `appid`, ' .
'`configkey`, `configvalue`) VALUES (?, ?, ?, ?)',
$entry
);
}

$value = $config->getUserKeys('userFetch', 'appFetch1');
$this->assertEquals(['123', '456'], $value);
$this->assertIsString($value[0]);
$this->assertIsString($value[1]);

// cleanup
$this->connection->executeUpdate('DELETE FROM `*PREFIX*preferences`');
}

public function testGetUserValueDefault() {
$config = $this->getConfig();

Expand Down