summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCôme Chilliet <come.chilliet@nextcloud.com>2022-01-18 15:45:00 +0100
committerCôme Chilliet <come.chilliet@nextcloud.com>2022-01-24 11:16:44 +0100
commita6eb7dc676dd18ad153fc920f9b13e802974c94f (patch)
tree9b30259c1eb93ac3f7e1614c6440b2d228cb6db8
parentd630af4ca80d4e0ab37197df2bc8a0f98ea674a4 (diff)
downloadnextcloud-server-a6eb7dc676dd18ad153fc920f9b13e802974c94f.tar.gz
nextcloud-server-a6eb7dc676dd18ad153fc920f9b13e802974c94f.zip
Fix signatures and null $userId corner case
Configuration values are sometimes queried when there is no user in session, so $userId is null and we just want to return the default Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
-rw-r--r--lib/private/AllConfig.php10
-rw-r--r--lib/public/IConfig.php2
2 files changed, 6 insertions, 6 deletions
diff --git a/lib/private/AllConfig.php b/lib/private/AllConfig.php
index b26bcc06a2b..7d32c1dbc6c 100644
--- a/lib/private/AllConfig.php
+++ b/lib/private/AllConfig.php
@@ -312,7 +312,7 @@ class AllConfig implements \OCP\IConfig {
/**
* Getting a user defined value
*
- * @param string $userId the userId of the user that we want to store the value under
+ * @param ?string $userId the userId of the user that we want to store the value under
* @param string $appName the appName that we stored the value under
* @param string $key the key under which the value is being stored
* @param mixed $default the default value to be returned if the value isn't set
@@ -400,19 +400,19 @@ class AllConfig implements \OCP\IConfig {
/**
* Returns all user configs sorted by app of one user
*
- * @param string $userId the user ID to get the app configs from
+ * @param ?string $userId the user ID to get the app configs from
* @return array[] - 2 dimensional array with the following structure:
* [ $appId =>
* [ $key => $value ]
* ]
*/
- public function getAllUserValues(string $userId): array {
+ public function getAllUserValues(?string $userId): array {
if (isset($this->userCache[$userId])) {
return $this->userCache[$userId];
}
if ($userId === null || $userId === '') {
- $this->userCache[$userId] = [];
- return $this->userCache[$userId];
+ $this->userCache[''] = [];
+ return $this->userCache[''];
}
// TODO - FIXME
diff --git a/lib/public/IConfig.php b/lib/public/IConfig.php
index 31e62cc23c0..79dd72ca205 100644
--- a/lib/public/IConfig.php
+++ b/lib/public/IConfig.php
@@ -186,7 +186,7 @@ interface IConfig {
/**
* Shortcut for getting a user defined value
*
- * @param string $userId the userId of the user that we want to store the value under
+ * @param ?string $userId the userId of the user that we want to store the value under
* @param string $appName the appName that we stored the value under
* @param string $key the key under which the value is being stored
* @param mixed $default the default value to be returned if the value isn't set