Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
refactor: Extend rector to ocs/ and ocs-provider/
Signed-off-by: provokateurin <[email protected]>
  • Loading branch information
provokateurin committed May 15, 2025
commit 3b42c92d693357df80765268d4b32d8ba5b06a2d
4 changes: 2 additions & 2 deletions build/rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ public function shouldSkip(File $file, FullyQualifiedObjectType $fullyQualifiedO
->withPaths([
$nextcloudDir . '/apps',
$nextcloudDir . '/core',
$nextcloudDir . '/ocs',
$nextcloudDir . '/ocs-provider',
$nextcloudDir . '/console.php',
$nextcloudDir . '/cron.php',
$nextcloudDir . '/index.php',
Expand All @@ -63,8 +65,6 @@ public function shouldSkip(File $file, FullyQualifiedObjectType $fullyQualifiedO
$nextcloudDir . '/version.php',
// $nextcloudDir . '/config',
// $nextcloudDir . '/lib',
// $nextcloudDir . '/ocs',
// $nextcloudDir . '/ocs-provider',
// $nextcloudDir . '/tests',
// $nextcloudDir . '/themes',
])
Expand Down
6 changes: 5 additions & 1 deletion ocs/providers.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<?php

use OCP\IRequest;
use OCP\Server;

/**
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
Expand All @@ -9,7 +13,7 @@

header('Content-type: application/xml');

$request = \OC::$server->getRequest();
$request = Server::get(IRequest::class);

$url = $request->getServerProtocol() . '://' . substr($request->getServerHost() . $request->getRequestUri(), 0, -17) . 'ocs/v1.php/';

Expand Down
22 changes: 15 additions & 7 deletions ocs/v1.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

declare(strict_types=1);

use OC\Route\Router;
use OC\SystemConfig;
use OC\User\LoginException;
use OCP\IConfig;
use OCP\IRequest;
use OCP\IUserSession;
use OCP\Server;

/**
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
Expand All @@ -21,7 +29,7 @@
use Symfony\Component\Routing\Exception\ResourceNotFoundException;

if (Util::needUpgrade()
|| \OC::$server->getConfig()->getSystemValueBool('maintenance')) {
|| Server::get(IConfig::class)->getSystemValueBool('maintenance')) {
// since the behavior of apps or remotes are unpredictable during
// an upgrade, return a 503 directly
ApiHelper::respond(503, 'Service unavailable', ['X-Nextcloud-Maintenance-Mode' => '1'], 503);
Expand All @@ -42,11 +50,11 @@
// side effects in existing apps
OC_App::loadApps();

if (!\OC::$server->getUserSession()->isLoggedIn()) {
OC::handleLogin(\OC::$server->getRequest());
if (!Server::get(IUserSession::class)->isLoggedIn()) {
OC::handleLogin(Server::get(IRequest::class));
}

OC::$server->get(\OC\Route\Router::class)->match('/ocsapp' . \OC::$server->getRequest()->getRawPathInfo());
Server::get(Router::class)->match('/ocsapp' . Server::get(IRequest::class)->getRawPathInfo());
} catch (MaxDelayReached $ex) {
ApiHelper::respond(Http::STATUS_TOO_MANY_REQUESTS, $ex->getMessage());
} catch (ResourceNotFoundException $e) {
Expand All @@ -56,14 +64,14 @@
} catch (MethodNotAllowedException $e) {
ApiHelper::setContentType();
http_response_code(405);
} catch (\OC\User\LoginException $e) {
} catch (LoginException $e) {
ApiHelper::respond(OCSController::RESPOND_UNAUTHORISED, 'Unauthorised');
} catch (\Exception $e) {
\OCP\Server::get(LoggerInterface::class)->error($e->getMessage(), ['exception' => $e]);
Server::get(LoggerInterface::class)->error($e->getMessage(), ['exception' => $e]);

$txt = 'Internal Server Error' . "\n";
try {
if (\OC::$server->getSystemConfig()->getValue('debug', false)) {
if (Server::get(SystemConfig::class)->getValue('debug', false)) {
$txt .= $e->getMessage();
}
} catch (\Throwable $e) {
Expand Down
Loading