Skip to content

Commit 3d7ae44

Browse files
Merge pull request #51930 from nextcloud/fix/29-template-layout
[stable29] fix: ensure enabled themes are set on the template
2 parents 1526a64 + 5c3bb1d commit 3d7ae44

3 files changed

Lines changed: 28 additions & 22 deletions

File tree

apps/theming/lib/Service/ThemesService.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,7 @@ public function isEnabled(ITheme $theme): bool {
164164
}
165165

166166
/**
167-
* Get the list of all enabled themes IDs
168-
* for the logged-in user
167+
* Get the list of all enabled themes IDs for the current user.
169168
*
170169
* @return string[]
171170
*/

cypress/e2e/core/404-error.cy.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/**
2+
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
3+
* SPDX-License-Identifier: AGPL-3.0-or-later
4+
*/
5+
6+
describe('404 error page', { testIsolation: true }, () => {
7+
it('renders 404 page', () => {
8+
cy.visit('/doesnotexist', { failOnStatusCode: false })
9+
10+
cy.findByRole('heading', { name: /Page not found/ })
11+
.should('be.visible')
12+
cy.findByRole('link', { name: /Back to Nextcloud/ })
13+
.should('be.visible')
14+
.click()
15+
16+
cy.url()
17+
.should('match', /(\/index.php)\/login$/)
18+
})
19+
})

lib/private/TemplateLayout.php

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -112,13 +112,6 @@ public function __construct($renderAs, $appId = '') {
112112
} else {
113113
Util::addScript('core', 'unified-search', 'core');
114114
}
115-
// Set body data-theme
116-
$this->assign('enabledThemes', []);
117-
if ($this->appManager->isEnabledForUser('theming') && class_exists('\OCA\Theming\Service\ThemesService')) {
118-
/** @var \OCA\Theming\Service\ThemesService */
119-
$themesService = \OC::$server->get(\OCA\Theming\Service\ThemesService::class);
120-
$this->assign('enabledThemes', $themesService->getEnabledThemes());
121-
}
122115

123116
// Set logo link target
124117
$logoUrl = $this->config->getSystemValueString('logo_url', '');
@@ -183,23 +176,13 @@ public function __construct($renderAs, $appId = '') {
183176
if ($user) {
184177
$userDisplayName = $user->getDisplayName();
185178
}
186-
$theme = $this->config->getSystemValueString('enforce_theme', '');
187-
$this->assign('enabledThemes', $theme === '' ? [] : [$theme]);
188179
$this->assign('user_displayname', $userDisplayName);
189180
$this->assign('user_uid', \OC_User::getUser());
190181
} elseif ($renderAs === TemplateResponse::RENDER_AS_PUBLIC) {
191182
parent::__construct('core', 'layout.public');
192183
$this->assign('appid', $appId);
193184
$this->assign('bodyid', 'body-public');
194185

195-
// Set body data-theme
196-
$this->assign('enabledThemes', []);
197-
if ($this->appManager->isEnabledForUser('theming') && class_exists('\OCA\Theming\Service\ThemesService')) {
198-
/** @var \OCA\Theming\Service\ThemesService $themesService */
199-
$themesService = \OC::$server->get(\OCA\Theming\Service\ThemesService::class);
200-
$this->assign('enabledThemes', $themesService->getEnabledThemes());
201-
}
202-
203186
// Set logo link target
204187
$logoUrl = $this->config->getSystemValueString('logo_url', '');
205188
$this->assign('logoUrl', $logoUrl);
@@ -227,9 +210,14 @@ public function __construct($renderAs, $appId = '') {
227210
} else {
228211
parent::__construct('core', 'layout.base');
229212
}
230-
// Send the language and the locale to our layouts
231-
$lang = \OC::$server->getL10NFactory()->findLanguage();
232-
$locale = \OC::$server->getL10NFactory()->findLocale($lang);
213+
214+
// Set body data-theme
215+
$themesService = \OCP\Server::get(\OCA\Theming\Service\ThemesService::class);
216+
$this->assign('enabledThemes', $themesService->getEnabledThemes());
217+
218+
// Send the language, locale, and direction to our layouts
219+
$lang = \OC::$server->get(IFactory::class)->findLanguage();
220+
$locale = \OC::$server->get(IFactory::class)->findLocale($lang);
233221

234222
$lang = str_replace('_', '-', $lang);
235223
$this->assign('language', $lang);

0 commit comments

Comments
 (0)