Skip to content

Commit 521bb94

Browse files
committed
fix: Deprecate OC_App::getCurrentApp and remove its only use
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
1 parent 9cd3177 commit 521bb94

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

lib/private/TemplateLayout.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ public function __construct(
5858
private INavigationManager $navigationManager,
5959
private ITemplateManager $templateManager,
6060
private ServerVersion $serverVersion,
61+
private IRequest $request,
6162
) {
6263
}
6364

@@ -72,7 +73,8 @@ public function getPageTemplate(string $renderAs, string $appId): ITemplate {
7273
switch ($renderAs) {
7374
case TemplateResponse::RENDER_AS_USER:
7475
$page = $this->templateManager->getTemplate('core', 'layout.user');
75-
if (in_array(\OC_App::getCurrentApp(), ['settings','admin', 'help']) !== false) {
76+
$pathInfo = $this->request->getPathInfo();
77+
if ($pathInfo !== false && str_starts_with($pathInfo, '/settings/')) {
7678
$page->assign('bodyid', 'body-settings');
7779
} else {
7880
$page->assign('bodyid', 'body-user');
@@ -254,10 +256,8 @@ public function getPageTemplate(string $renderAs, string $appId): ITemplate {
254256
$page->append('jsfiles', $web . '/' . $file . $this->getVersionHashSuffix());
255257
}
256258

257-
$request = Server::get(IRequest::class);
258-
259259
try {
260-
$pathInfo = $request->getPathInfo();
260+
$pathInfo = $this->request->getPathInfo();
261261
} catch (\Exception $e) {
262262
$pathInfo = '';
263263
}
@@ -298,7 +298,7 @@ public function getPageTemplate(string $renderAs, string $appId): ITemplate {
298298
}
299299
}
300300

301-
if ($request->isUserAgent([Request::USER_AGENT_CLIENT_IOS, Request::USER_AGENT_SAFARI, Request::USER_AGENT_SAFARI_MOBILE])) {
301+
if ($this->request->isUserAgent([Request::USER_AGENT_CLIENT_IOS, Request::USER_AGENT_SAFARI, Request::USER_AGENT_SAFARI_MOBILE])) {
302302
// Prevent auto zoom with iOS but still allow user zoom
303303
// On chrome (and others) this does not work (will also disable user zoom)
304304
$page->assign('viewport_maximum_scale', '1.0');

lib/private/legacy/OC_App.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,7 @@ public static function getAppVersionByPath(string $path): string {
261261

262262
/**
263263
* get the id of loaded app
264+
* @deprecated 34.0.0 Don’t do that
264265
*/
265266
public static function getCurrentApp(): string {
266267
if (\OC::$CLI) {

0 commit comments

Comments
 (0)