diff --git a/public.php b/public.php index fc0e78695c9..9443367eb12 100644 --- a/public.php +++ b/public.php @@ -1,18 +1,22 @@ 'dav/appinfo/v1/publicwebdav.php', @@ -22,7 +26,7 @@ function resolveService(string $service): string { return $services[$service]; } - return \OC::$server->getConfig()->getAppValue('core', 'remote_' . $service); + return Server::get(IConfig::class)->getAppValue('core', 'remote_' . $service); } try { @@ -34,13 +38,13 @@ try { header("Content-Security-Policy: default-src 'none';"); // Check if Nextcloud is in maintenance mode - if (\OCP\Util::needUpgrade()) { + if (Util::needUpgrade()) { // since the behavior of apps or remotes are unpredictable during // an upgrade, return a 503 directly throw new \Exception('Service unavailable', 503); } - $request = \OC::$server->getRequest(); + $request = Server::get(IRequest::class); $pathInfo = $request->getPathInfo(); if ($pathInfo === false || $pathInfo === '') { throw new \Exception('Path not found', 404); @@ -64,18 +68,19 @@ try { $app = $parts[0]; // Load all required applications + $appManager = Server::get(IAppManager::class); \OC::$REQUESTEDAPP = $app; - OC_App::loadApps(['authentication']); - OC_App::loadApps(['extended_authentication']); - OC_App::loadApps(['filesystem', 'logging']); + $appManager->loadApps(['authentication']); + $appManager->loadApps(['extended_authentication']); + $appManager->loadApps(['filesystem', 'logging']); // Check if the app is enabled - if (!\OC::$server->getAppManager()->isEnabledForUser($app)) { + if (!$appManager->isEnabledForUser($app)) { throw new \Exception('App not installed: ' . $app); } // Load the app - OC_App::loadApp($app); + $appManager->loadApp($app); OC_User::setIncognitoMode(true); $baseuri = OC::$WEBROOT . '/public.php/' . $service . '/'; @@ -86,10 +91,10 @@ try { $status = 503; } //show the user a detailed error page - \OCP\Server::get(LoggerInterface::class)->error($ex->getMessage(), ['app' => 'public', 'exception' => $ex]); + Server::get(LoggerInterface::class)->error($ex->getMessage(), ['app' => 'public', 'exception' => $ex]); OC_Template::printExceptionErrorPage($ex, $status); } catch (Error $ex) { //show the user a detailed error page - \OCP\Server::get(LoggerInterface::class)->error($ex->getMessage(), ['app' => 'public', 'exception' => $ex]); + Server::get(LoggerInterface::class)->error($ex->getMessage(), ['app' => 'public', 'exception' => $ex]); OC_Template::printExceptionErrorPage($ex, 500); }