Skip to content

Commit 9bc946a

Browse files
Merge pull request #51933 from nextcloud/fix/master-template-layout
fix: ensure enabled (enforced) themes are always set on template layout
2 parents d8ff056 + cfdd691 commit 9bc946a

File tree

3 files changed

+24
-15
lines changed

3 files changed

+24
-15
lines changed

apps/theming/lib/Service/ThemesService.php

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

150150
/**
151-
* Get the list of all enabled themes IDs
152-
* for the logged-in user
151+
* Get the list of all enabled themes IDs for the current user.
153152
*
154153
* @return string[]
155154
*/

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: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,6 @@ public function getPageTemplate(string $renderAs, string $appId): ITemplate {
8080
} else {
8181
Util::addScript('core', 'unified-search', 'core');
8282
}
83-
// Set body data-theme
84-
$page->assign('enabledThemes', []);
85-
if ($this->appManager->isEnabledForUser('theming') && class_exists('\OCA\Theming\Service\ThemesService')) {
86-
$themesService = Server::get(\OCA\Theming\Service\ThemesService::class);
87-
$page->assign('enabledThemes', $themesService->getEnabledThemes());
88-
}
8983

9084
// Set logo link target
9185
$logoUrl = $this->config->getSystemValueString('logo_url', '');
@@ -164,13 +158,6 @@ public function getPageTemplate(string $renderAs, string $appId): ITemplate {
164158
$page->assign('appid', $appId);
165159
$page->assign('bodyid', 'body-public');
166160

167-
// Set body data-theme
168-
$page->assign('enabledThemes', []);
169-
if ($this->appManager->isEnabledForUser('theming') && class_exists('\OCA\Theming\Service\ThemesService')) {
170-
$themesService = Server::get(\OCA\Theming\Service\ThemesService::class);
171-
$page->assign('enabledThemes', $themesService->getEnabledThemes());
172-
}
173-
174161
// Set logo link target
175162
$logoUrl = $this->config->getSystemValueString('logo_url', '');
176163
$page->assign('logoUrl', $logoUrl);
@@ -210,6 +197,10 @@ public function getPageTemplate(string $renderAs, string $appId): ITemplate {
210197
$page->assign('locale', $locale);
211198
$page->assign('direction', $direction);
212199

200+
// Set body data-theme
201+
$themesService = Server::get(\OCA\Theming\Service\ThemesService::class);
202+
$page->assign('enabledThemes', $themesService->getEnabledThemes());
203+
213204
if ($this->config->getSystemValueBool('installed', false)) {
214205
if (empty(self::$versionHash)) {
215206
$v = $this->appManager->getAppInstalledVersions();

0 commit comments

Comments
 (0)