diff options
author | Joas Schilling <213943+nickvergessen@users.noreply.github.com> | 2024-03-19 20:26:55 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-19 20:26:55 +0100 |
commit | 4d0476fd8bb7e253dca4053a12e0ae41bd19adb5 (patch) | |
tree | 1c7db6d395dd4eff2cd4fb85d6e4c67479abd3b0 | |
parent | f8ad4ae852ebd456c2cfd497c2fece6a574ec9d9 (diff) | |
parent | 112b8bcbfb5f9abdfa40f3fa273ae695dabc9c20 (diff) | |
download | nextcloud-server-4d0476fd8bb7e253dca4053a12e0ae41bd19adb5.tar.gz nextcloud-server-4d0476fd8bb7e253dca4053a12e0ae41bd19adb5.zip |
Merge pull request #44337 from nextcloud/backport/44276/stable27
[stable27] fix(config): Make sure user keys are strings
-rw-r--r-- | lib/private/AllConfig.php | 2 | ||||
-rw-r--r-- | tests/lib/AllConfigTest.php | 25 |
2 files changed, 26 insertions, 1 deletions
diff --git a/lib/private/AllConfig.php b/lib/private/AllConfig.php index 92178d64635..7a54de2b7bb 100644 --- a/lib/private/AllConfig.php +++ b/lib/private/AllConfig.php @@ -334,7 +334,7 @@ class AllConfig implements IConfig { 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 []; } diff --git a/tests/lib/AllConfigTest.php b/tests/lib/AllConfigTest.php index fca4e8d8308..540eff42e51 100644 --- a/tests/lib/AllConfigTest.php +++ b/tests/lib/AllConfigTest.php @@ -277,6 +277,31 @@ class AllConfigTest extends \Test\TestCase { $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(); |