@@ -31,14 +31,14 @@ discard block |
||
| 31 | 31 | require_once __DIR__ . '/../lib/base.php'; |
| 32 | 32 | |
| 33 | 33 | if (\OCP\Util::needUpgrade() |
| 34 | - || \OC::$server->getConfig()->getSystemValueBool('maintenance')) { |
|
| 35 | - // since the behavior of apps or remotes are unpredictable during |
|
| 36 | - // an upgrade, return a 503 directly |
|
| 37 | - http_response_code(503); |
|
| 38 | - header('X-Nextcloud-Maintenance-Mode: 1'); |
|
| 39 | - $response = new \OC\OCS\Result(null, 503, 'Service unavailable'); |
|
| 40 | - OC_API::respond($response, OC_API::requestedFormat()); |
|
| 41 | - exit; |
|
| 34 | + || \OC::$server->getConfig()->getSystemValueBool('maintenance')) { |
|
| 35 | + // since the behavior of apps or remotes are unpredictable during |
|
| 36 | + // an upgrade, return a 503 directly |
|
| 37 | + http_response_code(503); |
|
| 38 | + header('X-Nextcloud-Maintenance-Mode: 1'); |
|
| 39 | + $response = new \OC\OCS\Result(null, 503, 'Service unavailable'); |
|
| 40 | + OC_API::respond($response, OC_API::requestedFormat()); |
|
| 41 | + exit; |
|
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | use Symfony\Component\Routing\Exception\ResourceNotFoundException; |
@@ -48,45 +48,45 @@ discard block |
||
| 48 | 48 | * Try the appframework routes |
| 49 | 49 | */ |
| 50 | 50 | try { |
| 51 | - OC_App::loadApps(['session']); |
|
| 52 | - OC_App::loadApps(['authentication']); |
|
| 51 | + OC_App::loadApps(['session']); |
|
| 52 | + OC_App::loadApps(['authentication']); |
|
| 53 | 53 | |
| 54 | - // load all apps to get all api routes properly setup |
|
| 55 | - // FIXME: this should ideally appear after handleLogin but will cause |
|
| 56 | - // side effects in existing apps |
|
| 57 | - OC_App::loadApps(); |
|
| 54 | + // load all apps to get all api routes properly setup |
|
| 55 | + // FIXME: this should ideally appear after handleLogin but will cause |
|
| 56 | + // side effects in existing apps |
|
| 57 | + OC_App::loadApps(); |
|
| 58 | 58 | |
| 59 | - if (!\OC::$server->getUserSession()->isLoggedIn()) { |
|
| 60 | - OC::handleLogin(\OC::$server->getRequest()); |
|
| 61 | - } |
|
| 59 | + if (!\OC::$server->getUserSession()->isLoggedIn()) { |
|
| 60 | + OC::handleLogin(\OC::$server->getRequest()); |
|
| 61 | + } |
|
| 62 | 62 | |
| 63 | - OC::$server->get(\OC\Route\Router::class)->match('/ocsapp'.\OC::$server->getRequest()->getRawPathInfo()); |
|
| 63 | + OC::$server->get(\OC\Route\Router::class)->match('/ocsapp'.\OC::$server->getRequest()->getRawPathInfo()); |
|
| 64 | 64 | } catch (ResourceNotFoundException $e) { |
| 65 | - OC_API::setContentType(); |
|
| 65 | + OC_API::setContentType(); |
|
| 66 | 66 | |
| 67 | - $format = \OC::$server->getRequest()->getParam('format', 'xml'); |
|
| 68 | - $txt = 'Invalid query, please check the syntax. API specifications are here:' |
|
| 69 | - .' http://www.freedesktop.org/wiki/Specifications/open-collaboration-services.'."\n"; |
|
| 70 | - OC_API::respond(new \OC\OCS\Result(null, \OCP\AppFramework\OCSController::RESPOND_NOT_FOUND, $txt), $format); |
|
| 67 | + $format = \OC::$server->getRequest()->getParam('format', 'xml'); |
|
| 68 | + $txt = 'Invalid query, please check the syntax. API specifications are here:' |
|
| 69 | + .' http://www.freedesktop.org/wiki/Specifications/open-collaboration-services.'."\n"; |
|
| 70 | + OC_API::respond(new \OC\OCS\Result(null, \OCP\AppFramework\OCSController::RESPOND_NOT_FOUND, $txt), $format); |
|
| 71 | 71 | } catch (MethodNotAllowedException $e) { |
| 72 | - OC_API::setContentType(); |
|
| 73 | - http_response_code(405); |
|
| 72 | + OC_API::setContentType(); |
|
| 73 | + http_response_code(405); |
|
| 74 | 74 | } catch (\OC\OCS\Exception $ex) { |
| 75 | - OC_API::respond($ex->getResult(), OC_API::requestedFormat()); |
|
| 75 | + OC_API::respond($ex->getResult(), OC_API::requestedFormat()); |
|
| 76 | 76 | } catch (\OC\User\LoginException $e) { |
| 77 | - OC_API::respond(new \OC\OCS\Result(null, \OCP\AppFramework\OCSController::RESPOND_UNAUTHORISED, 'Unauthorised')); |
|
| 77 | + OC_API::respond(new \OC\OCS\Result(null, \OCP\AppFramework\OCSController::RESPOND_UNAUTHORISED, 'Unauthorised')); |
|
| 78 | 78 | } catch (\Exception $e) { |
| 79 | - \OC::$server->getLogger()->logException($e); |
|
| 80 | - OC_API::setContentType(); |
|
| 79 | + \OC::$server->getLogger()->logException($e); |
|
| 80 | + OC_API::setContentType(); |
|
| 81 | 81 | |
| 82 | - $format = \OC::$server->getRequest()->getParam('format', 'xml'); |
|
| 83 | - $txt = 'Internal Server Error'."\n"; |
|
| 84 | - try { |
|
| 85 | - if (\OC::$server->getSystemConfig()->getValue('debug', false)) { |
|
| 86 | - $txt .= $e->getMessage(); |
|
| 87 | - } |
|
| 88 | - } catch (\Throwable $e) { |
|
| 89 | - // Just to be save |
|
| 90 | - } |
|
| 91 | - OC_API::respond(new \OC\OCS\Result(null, \OCP\AppFramework\OCSController::RESPOND_SERVER_ERROR, $txt), $format); |
|
| 82 | + $format = \OC::$server->getRequest()->getParam('format', 'xml'); |
|
| 83 | + $txt = 'Internal Server Error'."\n"; |
|
| 84 | + try { |
|
| 85 | + if (\OC::$server->getSystemConfig()->getValue('debug', false)) { |
|
| 86 | + $txt .= $e->getMessage(); |
|
| 87 | + } |
|
| 88 | + } catch (\Throwable $e) { |
|
| 89 | + // Just to be save |
|
| 90 | + } |
|
| 91 | + OC_API::respond(new \OC\OCS\Result(null, \OCP\AppFramework\OCSController::RESPOND_SERVER_ERROR, $txt), $format); |
|
| 92 | 92 | } |