]> source.dussan.org Git - nextcloud-server.git/commitdiff
fix(theming): Return default theme if the user never selected a theme backport/49112/stable29 49137/head
authorprovokateurin <kate@provokateurin.de>
Wed, 6 Nov 2024 15:20:38 +0000 (16:20 +0100)
committerbackportbot[bot] <backportbot[bot]@users.noreply.github.com>
Thu, 7 Nov 2024 19:15:18 +0000 (19:15 +0000)
Signed-off-by: provokateurin <kate@provokateurin.de>
apps/theming/lib/Service/ThemesService.php
apps/theming/tests/Service/ThemesServiceTest.php

index d080752a032a3b1a37348885f0c570da0332d4e0..8244e69e219113ece2ead95aebb6e9052f01a50f 100644 (file)
@@ -143,7 +143,7 @@ class ThemesService {
                        $this->setEnabledThemes($enabledThemes);
                        return $enabledThemes;
                }
-               
+
                return $themesIds;
        }
 
@@ -176,7 +176,7 @@ class ThemesService {
                }
 
                $enforcedTheme = $this->config->getSystemValueString('enforce_theme', '');
-               $enabledThemes = json_decode($this->config->getUserValue($user->getUID(), Application::APP_ID, 'enabled-themes', '[]'));
+               $enabledThemes = json_decode($this->config->getUserValue($user->getUID(), Application::APP_ID, 'enabled-themes', '["default"]'));
                if ($enforcedTheme !== '') {
                        return array_merge([$enforcedTheme], $enabledThemes);
                }
index 4728a2cf64ed5a6f4936e4921c74eec951e61ff1..1b152b00721248e8430a8cde871d88e562264349 100644 (file)
@@ -138,8 +138,8 @@ class ThemesServiceTest extends TestCase {
 
        public function dataTestEnableTheme() {
                return [
-                       ['default', [], ['default']],
-                       ['dark', [], ['dark']],
+                       ['default', ['default'], ['default']],
+                       ['dark', ['default'], ['dark']],
                        ['dark', ['dark'], ['dark']],
                        ['opendyslexic', ['dark'], ['dark', 'opendyslexic']],
                        ['dark', ['light-highcontrast', 'opendyslexic'], ['opendyslexic', 'dark']],
@@ -164,7 +164,7 @@ class ThemesServiceTest extends TestCase {
 
                $this->config->expects($this->once())
                        ->method('getUserValue')
-                       ->with('user', Application::APP_ID, 'enabled-themes', '[]')
+                       ->with('user', Application::APP_ID, 'enabled-themes', '["default"]')
                        ->willReturn(json_encode($enabledThemes));
 
                $this->assertEquals($expectedEnabled, $this->themesService->enableTheme($this->themes[$toEnable]));
@@ -173,7 +173,7 @@ class ThemesServiceTest extends TestCase {
 
        public function dataTestDisableTheme() {
                return [
-                       ['dark', [], []],
+                       ['dark', ['default'], ['default']],
                        ['dark', ['dark'], []],
                        ['opendyslexic', ['dark', 'opendyslexic'], ['dark'], ],
                        ['light-highcontrast', ['opendyslexic'], ['opendyslexic']],
@@ -198,7 +198,7 @@ class ThemesServiceTest extends TestCase {
 
                $this->config->expects($this->once())
                        ->method('getUserValue')
-                       ->with('user', Application::APP_ID, 'enabled-themes', '[]')
+                       ->with('user', Application::APP_ID, 'enabled-themes', '["default"]')
                        ->willReturn(json_encode($enabledThemes));
 
 
@@ -232,7 +232,7 @@ class ThemesServiceTest extends TestCase {
 
                $this->config->expects($this->once())
                        ->method('getUserValue')
-                       ->with('user', Application::APP_ID, 'enabled-themes', '[]')
+                       ->with('user', Application::APP_ID, 'enabled-themes', '["default"]')
                        ->willReturn(json_encode($enabledThemes));
 
 
@@ -251,14 +251,14 @@ class ThemesServiceTest extends TestCase {
 
                $this->config->expects($this->once())
                        ->method('getUserValue')
-                       ->with('user', Application::APP_ID, 'enabled-themes', '[]')
-                       ->willReturn(json_encode([]));
+                       ->with('user', Application::APP_ID, 'enabled-themes', '["default"]')
+                       ->willReturn(json_encode(['default']));
                $this->config->expects($this->once())
                        ->method('getSystemValueString')
                        ->with('enforce_theme', '')
                        ->willReturn('');
 
-               $this->assertEquals([], $this->themesService->getEnabledThemes());
+               $this->assertEquals(['default'], $this->themesService->getEnabledThemes());
        }
 
        public function testGetEnabledThemesEnforced() {
@@ -273,7 +273,7 @@ class ThemesServiceTest extends TestCase {
 
                $this->config->expects($this->once())
                        ->method('getUserValue')
-                       ->with('user', Application::APP_ID, 'enabled-themes', '[]')
+                       ->with('user', Application::APP_ID, 'enabled-themes', '["default"]')
                        ->willReturn(json_encode([]));
                $this->config->expects($this->once())
                        ->method('getSystemValueString')