From 15fb15bc1436f9659feefd82031e389a24ad3117 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=B4me=20Chilliet?= Date: Thu, 8 Feb 2024 15:10:31 +0100 Subject: [PATCH] chore(index.php): Use strict_types and Server::get in index.php MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Côme Chilliet --- index.php | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/index.php b/index.php index 235a33c8317..cb9f4d460bd 100644 --- a/index.php +++ b/index.php @@ -1,8 +1,12 @@ + * @author Côme Chilliet * @author Joas Schilling * @author Jörn Friedrich Dreyer * @author Lukas Reschke @@ -28,33 +32,39 @@ * along with this program. If not, see * */ + require_once __DIR__ . '/lib/versioncheck.php'; +use OC\ServiceUnavailableException; +use OC\User\LoginException; +use OCP\HintException; +use OCP\IRequest; use OCP\Security\Bruteforce\MaxDelayReached; +use OCP\Server; use Psr\Log\LoggerInterface; try { require_once __DIR__ . '/lib/base.php'; OC::handleRequest(); -} catch (\OC\ServiceUnavailableException $ex) { - \OC::$server->get(LoggerInterface::class)->error($ex->getMessage(), [ +} catch (ServiceUnavailableException $ex) { + Server::get(LoggerInterface::class)->error($ex->getMessage(), [ 'app' => 'index', 'exception' => $ex, ]); //show the user a detailed error page OC_Template::printExceptionErrorPage($ex, 503); -} catch (\OCP\HintException $ex) { +} catch (HintException $ex) { try { OC_Template::printErrorPage($ex->getMessage(), $ex->getHint(), 503); } catch (Exception $ex2) { try { - \OC::$server->get(LoggerInterface::class)->error($ex->getMessage(), [ + Server::get(LoggerInterface::class)->error($ex->getMessage(), [ 'app' => 'index', 'exception' => $ex, ]); - \OC::$server->get(LoggerInterface::class)->error($ex2->getMessage(), [ + Server::get(LoggerInterface::class)->error($ex2->getMessage(), [ 'app' => 'index', 'exception' => $ex2, ]); @@ -65,8 +75,8 @@ try { //show the user a detailed error page OC_Template::printExceptionErrorPage($ex, 500); } -} catch (\OC\User\LoginException $ex) { - $request = \OC::$server->getRequest(); +} catch (LoginException $ex) { + $request = Server::get(IRequest::class); /** * Routes with the @CORS annotation and other API endpoints should * not return a webpage, so we only print the error page when html is accepted, @@ -80,7 +90,7 @@ try { } OC_Template::printErrorPage($ex->getMessage(), $ex->getMessage(), 401); } catch (MaxDelayReached $ex) { - $request = \OC::$server->getRequest(); + $request = Server::get(IRequest::class); /** * Routes with the @CORS annotation and other API endpoints should * not return a webpage, so we only print the error page when html is accepted, @@ -95,7 +105,7 @@ try { http_response_code(429); OC_Template::printGuestPage('core', '429'); } catch (Exception $ex) { - \OC::$server->get(LoggerInterface::class)->error($ex->getMessage(), [ + Server::get(LoggerInterface::class)->error($ex->getMessage(), [ 'app' => 'index', 'exception' => $ex, ]); @@ -104,7 +114,7 @@ try { OC_Template::printExceptionErrorPage($ex, 500); } catch (Error $ex) { try { - \OC::$server->get(LoggerInterface::class)->error($ex->getMessage(), [ + Server::get(LoggerInterface::class)->error($ex->getMessage(), [ 'app' => 'index', 'exception' => $ex, ]);