aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files/lib
diff options
context:
space:
mode:
authorJohn Molakvoæ <skjnldsv@protonmail.com>2022-12-28 19:08:54 +0100
committerJohn Molakvoæ <skjnldsv@protonmail.com>2023-01-04 16:46:16 +0100
commit0a3ef8b74bffc9b1cb6ef21695037d52aabd3ee1 (patch)
tree673c1fa994320800bfceb33eb45299137c15488d /apps/files/lib
parent5b9a8f0407a9e3fe7e00f0fc9284ea986905f1b5 (diff)
downloadnextcloud-server-0a3ef8b74bffc9b1cb6ef21695037d52aabd3ee1.tar.gz
nextcloud-server-0a3ef8b74bffc9b1cb6ef21695037d52aabd3ee1.zip
Fixing tests
Signed-off-by: John Molakvoæ <skjnldsv@protonmail.com>
Diffstat (limited to 'apps/files/lib')
-rw-r--r--apps/files/lib/Controller/ApiController.php2
-rw-r--r--apps/files/lib/Controller/ViewController.php14
-rw-r--r--apps/files/lib/Service/UserConfig.php11
3 files changed, 13 insertions, 14 deletions
diff --git a/apps/files/lib/Controller/ApiController.php b/apps/files/lib/Controller/ApiController.php
index 76597b7a018..f2329fc384b 100644
--- a/apps/files/lib/Controller/ApiController.php
+++ b/apps/files/lib/Controller/ApiController.php
@@ -289,7 +289,7 @@ class ApiController extends Controller {
* @param string|bool $value
* @return JSONResponse
*/
- public function setConfig(string $key, string|bool $value): JSONResponse {
+ public function setConfig(string $key, $value): JSONResponse {
try {
$this->userConfig->setConfig($key, (string)$value);
} catch (\InvalidArgumentException $e) {
diff --git a/apps/files/lib/Controller/ViewController.php b/apps/files/lib/Controller/ViewController.php
index 4e81b630bab..ea589807767 100644
--- a/apps/files/lib/Controller/ViewController.php
+++ b/apps/files/lib/Controller/ViewController.php
@@ -175,13 +175,13 @@ class ViewController extends Controller {
*/
public function index($dir = '', $view = '', $fileid = null, $fileNotFound = false, $openfile = null) {
- // if ($fileid !== null && $dir === '') {
- // try {
- // return $this->redirectToFile($fileid);
- // } catch (NotFoundException $e) {
- // return new RedirectResponse($this->urlGenerator->linkToRoute('files.view.index', ['fileNotFound' => true]));
- // }
- // }
+ if ($fileid !== null && $dir === '') {
+ try {
+ return $this->redirectToFile($fileid);
+ } catch (NotFoundException $e) {
+ return new RedirectResponse($this->urlGenerator->linkToRoute('files.view.index', ['fileNotFound' => true]));
+ }
+ }
$nav = new \OCP\Template('files', 'appnavigation', '');
diff --git a/apps/files/lib/Service/UserConfig.php b/apps/files/lib/Service/UserConfig.php
index 7ccf7008512..3a498805910 100644
--- a/apps/files/lib/Service/UserConfig.php
+++ b/apps/files/lib/Service/UserConfig.php
@@ -42,8 +42,7 @@ class UserConfig {
];
protected IConfig $config;
- /** @var \OCP\IUser|null */
- protected mixed $user = null;
+ protected ?IUser $user = null;
public function __construct(IConfig $config, IUserSession $userSession) {
$this->config = $config;
@@ -81,7 +80,7 @@ class UserConfig {
* @param string $key a valid config key
* @return string|bool
*/
- private function getDefaultConfigValue(string $key): string|bool {
+ private function getDefaultConfigValue(string $key) {
foreach (self::ALLOWED_CONFIGS as $config) {
if ($config['key'] === $key) {
return $config['default'];
@@ -94,11 +93,11 @@ class UserConfig {
* Set a user config
*
* @param string $key
- * @param string $value
+ * @param string|bool $value
* @throws \Exception
* @throws \InvalidArgumentException
*/
- public function setConfig($key, $value) {
+ public function setConfig(string $key, $value): void {
if ($this->user === null) {
throw new \Exception('No user logged in');
}
@@ -129,7 +128,7 @@ class UserConfig {
}
$userId = $this->user->getUID();
- $userConfigs = array_map(function(string $key) use ($userId): string|bool {
+ $userConfigs = array_map(function(string $key) use ($userId) {
$value = $this->config->getUserValue($userId, Application::APP_ID, $key, $this->getDefaultConfigValue($key));
// If the default is expected to be a boolean, we need to cast the value
if (is_bool($this->getDefaultConfigValue($key))) {