11<?php
22
3+ use OC \ServiceUnavailableException ;
4+ use OCP \IConfig ;
5+ use OCP \Util ;
6+
37/**
48 * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
59 * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
@@ -35,7 +39,7 @@ function handleException(Exception|Error $e): void {
3539 // we shall not log on RemoteException
3640 $ server ->addPlugin (new ExceptionLoggerPlugin ('webdav ' , \OCP \Server::get (LoggerInterface::class)));
3741 }
38- $ server ->on ('beforeMethod:* ' , function () use ($ e ) {
42+ $ server ->on ('beforeMethod:* ' , function () use ($ e ): void {
3943 if ($ e instanceof RemoteException) {
4044 switch ($ e ->getCode ()) {
4145 case 503 :
@@ -51,7 +55,7 @@ function handleException(Exception|Error $e): void {
5155 $ server ->exec ();
5256 } else {
5357 $ statusCode = 500 ;
54- if ($ e instanceof \ OC \ ServiceUnavailableException) {
58+ if ($ e instanceof ServiceUnavailableException) {
5559 $ statusCode = 503 ;
5660 }
5761 if ($ e instanceof RemoteException) {
@@ -86,7 +90,7 @@ function resolveService($service) {
8690 return $ services [$ service ];
8791 }
8892
89- return \OC :: $ server -> getConfig ( )->getAppValue ('core ' , 'remote_ ' . $ service );
93+ return \OCP \Server:: get (IConfig::class )->getAppValue ('core ' , 'remote_ ' . $ service );
9094}
9195
9296try {
@@ -97,13 +101,13 @@ function resolveService($service) {
97101 // this policy with a softer one if debug mode is enabled.
98102 header ("Content-Security-Policy: default-src 'none'; " );
99103
100- if (\ OCP \ Util::needUpgrade ()) {
104+ if (Util::needUpgrade ()) {
101105 // since the behavior of apps or remotes are unpredictable during
102106 // an upgrade, return a 503 directly
103107 throw new RemoteException ('Service unavailable ' , 503 );
104108 }
105109
106- $ request = \OC :: $ server -> getRequest ( );
110+ $ request = \OCP \Server:: get (IRequest::class );
107111 $ pathInfo = $ request ->getPathInfo ();
108112 if ($ pathInfo === false || $ pathInfo === '' ) {
109113 throw new RemoteException ('Path not found ' , 404 );
0 commit comments