mirror of
https://github.com/nextcloud/server.git
synced 2025-12-18 15:56:14 -05:00
refactor: Extend rector to all top-level files
Signed-off-by: provokateurin <kate@provokateurin.de>
This commit is contained in:
parent
c62fa55007
commit
6d6d83d3d9
5 changed files with 40 additions and 19 deletions
|
|
@ -53,7 +53,14 @@ $config = RectorConfig::configure()
|
|||
->withPaths([
|
||||
$nextcloudDir . '/apps',
|
||||
$nextcloudDir . '/core',
|
||||
$nextcloudDir . '/console.php',
|
||||
$nextcloudDir . '/cron.php',
|
||||
$nextcloudDir . '/index.php',
|
||||
$nextcloudDir . '/occ',
|
||||
$nextcloudDir . '/public.php',
|
||||
$nextcloudDir . '/remote.php',
|
||||
$nextcloudDir . '/status.php',
|
||||
$nextcloudDir . '/version.php',
|
||||
// $nextcloudDir . '/config',
|
||||
// $nextcloudDir . '/lib',
|
||||
// $nextcloudDir . '/ocs',
|
||||
|
|
|
|||
13
console.php
13
console.php
|
|
@ -2,6 +2,9 @@
|
|||
|
||||
declare(strict_types=1);
|
||||
|
||||
use OCP\IConfig;
|
||||
use OCP\Server;
|
||||
|
||||
/**
|
||||
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
|
||||
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
|
||||
|
|
@ -37,7 +40,7 @@ try {
|
|||
exit(1);
|
||||
}
|
||||
|
||||
$config = \OCP\Server::get(\OCP\IConfig::class);
|
||||
$config = Server::get(IConfig::class);
|
||||
set_exception_handler('exceptionHandler');
|
||||
|
||||
if (!function_exists('posix_getuid')) {
|
||||
|
|
@ -71,10 +74,10 @@ try {
|
|||
echo "Additionally the function 'pcntl_signal' and 'pcntl_signal_dispatch' need to be enabled in your php.ini." . PHP_EOL;
|
||||
}
|
||||
|
||||
$eventLogger = \OCP\Server::get(IEventLogger::class);
|
||||
$eventLogger = Server::get(IEventLogger::class);
|
||||
$eventLogger->start('console:build_application', 'Build Application instance and load commands');
|
||||
|
||||
$application = \OCP\Server::get(Application::class);
|
||||
$application = Server::get(Application::class);
|
||||
/* base.php will have removed eventual debug options from argv in $_SERVER */
|
||||
$argv = $_SERVER['argv'];
|
||||
$input = new ArgvInput($argv);
|
||||
|
|
@ -88,10 +91,10 @@ try {
|
|||
|
||||
$eventLogger->end('console:run');
|
||||
|
||||
$profiler = \OCP\Server::get(IProfiler::class);
|
||||
$profiler = Server::get(IProfiler::class);
|
||||
if ($profiler->isEnabled()) {
|
||||
$eventLogger->end('runtime');
|
||||
$profile = $profiler->collect(\OCP\Server::get(IRequest::class), new Response());
|
||||
$profile = $profiler->collect(Server::get(IRequest::class), new Response());
|
||||
$profile->setMethod('occ');
|
||||
$profile->setUrl(implode(' ', $argv));
|
||||
$profiler->saveProfile($profile);
|
||||
|
|
|
|||
21
cron.php
21
cron.php
|
|
@ -2,6 +2,11 @@
|
|||
|
||||
declare(strict_types=1);
|
||||
|
||||
use OC\Files\SetupManager;
|
||||
use OC\Session\CryptoWrapper;
|
||||
use OC\Session\Memory;
|
||||
use OCP\ILogger;
|
||||
|
||||
/**
|
||||
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
|
||||
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
|
||||
|
|
@ -64,8 +69,8 @@ Options:
|
|||
$verbose = isset($argv[1]) && ($argv[1] === '-v' || $argv[1] === '--verbose');
|
||||
|
||||
// initialize a dummy memory session
|
||||
$session = new \OC\Session\Memory();
|
||||
$cryptoWrapper = \OC::$server->getSessionCryptoWrapper();
|
||||
$session = new Memory();
|
||||
$cryptoWrapper = Server::get(CryptoWrapper::class);
|
||||
$session = $cryptoWrapper->wrapSession($session);
|
||||
\OC::$server->setSession($session);
|
||||
|
||||
|
|
@ -177,11 +182,11 @@ Options:
|
|||
$timeSpent = $timeAfter - $timeBefore;
|
||||
if ($timeSpent > $cronInterval) {
|
||||
$logLevel = match (true) {
|
||||
$timeSpent > $cronInterval * 128 => \OCP\ILogger::FATAL,
|
||||
$timeSpent > $cronInterval * 64 => \OCP\ILogger::ERROR,
|
||||
$timeSpent > $cronInterval * 16 => \OCP\ILogger::WARN,
|
||||
$timeSpent > $cronInterval * 8 => \OCP\ILogger::INFO,
|
||||
default => \OCP\ILogger::DEBUG,
|
||||
$timeSpent > $cronInterval * 128 => ILogger::FATAL,
|
||||
$timeSpent > $cronInterval * 64 => ILogger::ERROR,
|
||||
$timeSpent > $cronInterval * 16 => ILogger::WARN,
|
||||
$timeSpent > $cronInterval * 8 => ILogger::INFO,
|
||||
default => ILogger::DEBUG,
|
||||
};
|
||||
$logger->log(
|
||||
$logLevel,
|
||||
|
|
@ -206,7 +211,7 @@ Options:
|
|||
}
|
||||
|
||||
// clean up after unclean jobs
|
||||
Server::get(\OC\Files\SetupManager::class)->tearDown();
|
||||
Server::get(SetupManager::class)->tearDown();
|
||||
$tempManager->clean();
|
||||
|
||||
if ($verbose) {
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
declare(strict_types=1);
|
||||
|
||||
use OC\ServiceUnavailableException;
|
||||
|
||||
/**
|
||||
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
|
||||
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
|
||||
|
|
@ -88,7 +90,7 @@ try {
|
|||
require_once $file;
|
||||
} catch (Exception $ex) {
|
||||
$status = 500;
|
||||
if ($ex instanceof \OC\ServiceUnavailableException) {
|
||||
if ($ex instanceof ServiceUnavailableException) {
|
||||
$status = 503;
|
||||
}
|
||||
//show the user a detailed error page
|
||||
|
|
|
|||
14
remote.php
14
remote.php
|
|
@ -1,5 +1,9 @@
|
|||
<?php
|
||||
|
||||
use OC\ServiceUnavailableException;
|
||||
use OCP\IConfig;
|
||||
use OCP\Util;
|
||||
|
||||
/**
|
||||
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
|
||||
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
|
||||
|
|
@ -35,7 +39,7 @@ function handleException(Exception|Error $e): void {
|
|||
// we shall not log on RemoteException
|
||||
$server->addPlugin(new ExceptionLoggerPlugin('webdav', \OCP\Server::get(LoggerInterface::class)));
|
||||
}
|
||||
$server->on('beforeMethod:*', function () use ($e) {
|
||||
$server->on('beforeMethod:*', function () use ($e): void {
|
||||
if ($e instanceof RemoteException) {
|
||||
switch ($e->getCode()) {
|
||||
case 503:
|
||||
|
|
@ -51,7 +55,7 @@ function handleException(Exception|Error $e): void {
|
|||
$server->exec();
|
||||
} else {
|
||||
$statusCode = 500;
|
||||
if ($e instanceof \OC\ServiceUnavailableException) {
|
||||
if ($e instanceof ServiceUnavailableException) {
|
||||
$statusCode = 503;
|
||||
}
|
||||
if ($e instanceof RemoteException) {
|
||||
|
|
@ -86,7 +90,7 @@ function resolveService($service) {
|
|||
return $services[$service];
|
||||
}
|
||||
|
||||
return \OC::$server->getConfig()->getAppValue('core', 'remote_' . $service);
|
||||
return \OCP\Server::get(IConfig::class)->getAppValue('core', 'remote_' . $service);
|
||||
}
|
||||
|
||||
try {
|
||||
|
|
@ -97,13 +101,13 @@ try {
|
|||
// this policy with a softer one if debug mode is enabled.
|
||||
header("Content-Security-Policy: default-src 'none';");
|
||||
|
||||
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 RemoteException('Service unavailable', 503);
|
||||
}
|
||||
|
||||
$request = \OC::$server->getRequest();
|
||||
$request = \OCP\Server::get(IRequest::class);
|
||||
$pathInfo = $request->getPathInfo();
|
||||
if ($pathInfo === false || $pathInfo === '') {
|
||||
throw new RemoteException('Path not found', 404);
|
||||
|
|
|
|||
Loading…
Reference in a new issue