Browse Source

refactor: Extend rector to core/

Signed-off-by: provokateurin <kate@provokateurin.de>
pull/52820/head
provokateurin 7 months ago
parent
commit
82fb8f8508
Failed to extract signature
  1. 7
      apps/files/lib/Command/Copy.php
  2. 7
      apps/files/lib/Command/Move.php
  3. 2
      apps/files_trashbin/tests/TrashbinTest.php
  4. 2
      apps/files_versions/tests/VersioningTest.php
  5. 5
      apps/settings/lib/UserMigration/AccountMigrator.php
  6. 2
      build/rector.php
  7. 4
      core/Application.php
  8. 2
      core/BackgroundJobs/CheckForUserCertificates.php
  9. 3
      core/BackgroundJobs/GenerateMetadataJob.php
  10. 2
      core/BackgroundJobs/LookupServerSendCheckBackgroundJob.php
  11. 3
      core/Command/App/Update.php
  12. 8
      core/Command/Background/Job.php
  13. 9
      core/Command/Background/JobBase.php
  14. 13
      core/Command/Broadcast/Test.php
  15. 6
      core/Command/Db/ConvertType.php
  16. 2
      core/Command/Encryption/ListModules.php
  17. 3
      core/Command/Info/File.php
  18. 6
      core/Command/Info/FileUtils.php
  19. 5
      core/Command/Log/File.php
  20. 3
      core/Command/Maintenance/Install.php
  21. 3
      core/Command/Maintenance/UpdateHtaccess.php
  22. 2
      core/Command/Preview/Repair.php
  23. 37
      core/Command/Upgrade.php
  24. 3
      core/Command/User/Info.php
  25. 2
      core/Command/User/LastSeen.php
  26. 9
      core/Command/User/SyncAccountDataCommand.php
  27. 13
      core/Command/User/Welcome.php
  28. 3
      core/Controller/AppPasswordController.php
  29. 13
      core/Controller/AvatarController.php
  30. 10
      core/Controller/ClientFlowLoginController.php
  31. 3
      core/Controller/ClientFlowLoginV2Controller.php
  32. 3
      core/Controller/ErrorController.php
  33. 2
      core/Controller/GuestAvatarController.php
  34. 3
      core/Controller/HoverCardController.php
  35. 6
      core/Controller/LoginController.php
  36. 15
      core/Controller/LostController.php
  37. 3
      core/Controller/OCMController.php
  38. 3
      core/Controller/OCSController.php
  39. 5
      core/Controller/PreviewController.php
  40. 3
      core/Controller/ReferenceApiController.php
  41. 6
      core/Controller/SetupController.php
  42. 14
      core/Controller/TaskProcessingApiController.php
  43. 3
      core/Controller/TeamsApiController.php
  44. 3
      core/Controller/TextProcessingApiController.php
  45. 3
      core/Controller/TextToImageApiController.php
  46. 3
      core/Controller/TranslationApiController.php
  47. 3
      core/Controller/WhatsNewController.php
  48. 3
      core/Migrations/Version14000Date20180626223656.php
  49. 3
      core/Migrations/Version14000Date20180712153140.php
  50. 54
      core/ajax/update.php
  51. 267
      core/register_command.php
  52. 4
      core/strings.php
  53. 2
      core/templates/403.php
  54. 4
      core/templates/404.php
  55. 2
      core/templates/layout.user.php
  56. 2
      core/templates/login.php
  57. 2
      core/templates/loginflow/authpicker.php
  58. 2
      core/templates/loginflow/grant.php
  59. 2
      core/templates/loginflowv2/authpicker.php
  60. 2
      core/templates/loginflowv2/grant.php
  61. 6
      core/templates/print_exception.php
  62. 6
      core/templates/print_xml_exception.php
  63. 2
      core/templates/recommendedapps.php
  64. 2
      core/templates/success.php
  65. 6
      core/templates/twofactorselectchallenge.php
  66. 2
      core/templates/twofactorsetupselection.php
  67. 2
      core/templates/twofactorshowchallenge.php

7
apps/files/lib/Command/Copy.php

@ -19,10 +19,9 @@ use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Question\ConfirmationQuestion;
class Copy extends Command {
private FileUtils $fileUtils;
public function __construct(FileUtils $fileUtils) {
$this->fileUtils = $fileUtils;
public function __construct(
private FileUtils $fileUtils,
) {
parent::__construct();
}

7
apps/files/lib/Command/Move.php

@ -20,10 +20,9 @@ use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Question\ConfirmationQuestion;
class Move extends Command {
private FileUtils $fileUtils;
public function __construct(FileUtils $fileUtils) {
$this->fileUtils = $fileUtils;
public function __construct(
private FileUtils $fileUtils,
) {
parent::__construct();
}

2
apps/files_trashbin/tests/TrashbinTest.php

@ -118,7 +118,7 @@ class TrashbinTest extends \Test\TestCase {
$config = Server::get(IConfig::class);
$mockConfig = $this->getMockBuilder(AllConfig::class)
->onlyMethods(['getSystemValue'])
->setConstructorArgs([Server::get(\OC\SystemConfig::class)])
->setConstructorArgs([Server::get(SystemConfig::class)])
->getMock();
$mockConfig->expects($this->any())
->method('getSystemValue')

2
apps/files_versions/tests/VersioningTest.php

@ -85,7 +85,7 @@ class VersioningTest extends \Test\TestCase {
$config = Server::get(IConfig::class);
$mockConfig = $this->getMockBuilder(AllConfig::class)
->onlyMethods(['getSystemValue'])
->setConstructorArgs([Server::get(\OC\SystemConfig::class)])
->setConstructorArgs([Server::get(SystemConfig::class)])
->getMock();
$mockConfig->expects($this->any())
->method('getSystemValue')

5
apps/settings/lib/UserMigration/AccountMigrator.php

@ -35,8 +35,6 @@ class AccountMigrator implements IMigrator, ISizeEstimationMigrator {
private ProfileManager $profileManager;
private ProfileConfigMapper $configMapper;
private const PATH_ROOT = Application::APP_ID . '/';
private const PATH_ACCOUNT_FILE = AccountMigrator::PATH_ROOT . 'account.json';
@ -49,11 +47,10 @@ class AccountMigrator implements IMigrator, ISizeEstimationMigrator {
private IAccountManager $accountManager,
private IAvatarManager $avatarManager,
ProfileManager $profileManager,
ProfileConfigMapper $configMapper,
private ProfileConfigMapper $configMapper,
private IL10N $l10n,
) {
$this->profileManager = $profileManager;
$this->configMapper = $configMapper;
}
/**

2
build/rector.php

@ -52,9 +52,9 @@ class NextcloudNamespaceSkipVoter implements ClassNameImportSkipVoterInterface {
$config = RectorConfig::configure()
->withPaths([
$nextcloudDir . '/apps',
$nextcloudDir . '/core',
$nextcloudDir . '/status.php',
// $nextcloudDir . '/config',
// $nextcloudDir . '/core',
// $nextcloudDir . '/lib',
// $nextcloudDir . '/ocs',
// $nextcloudDir . '/ocs-provider',

4
core/Application.php

@ -54,7 +54,7 @@ class Application extends App {
$notificationManager->registerNotifierService(CoreNotifier::class);
$notificationManager->registerNotifierService(AuthenticationNotifier::class);
$eventDispatcher->addListener(AddMissingIndicesEvent::class, function (AddMissingIndicesEvent $event) {
$eventDispatcher->addListener(AddMissingIndicesEvent::class, function (AddMissingIndicesEvent $event): void {
$event->addMissingIndex(
'share',
'share_with_index',
@ -244,7 +244,7 @@ class Application extends App {
);
});
$eventDispatcher->addListener(AddMissingPrimaryKeyEvent::class, function (AddMissingPrimaryKeyEvent $event) {
$eventDispatcher->addListener(AddMissingPrimaryKeyEvent::class, function (AddMissingPrimaryKeyEvent $event): void {
$event->addMissingPrimaryKey(
'federated_reshares',
'federated_res_pk',

2
core/BackgroundJobs/CheckForUserCertificates.php

@ -32,7 +32,7 @@ class CheckForUserCertificates extends QueuedJob {
*/
public function run($arguments): void {
$uploadList = [];
$this->userManager->callForSeenUsers(function (IUser $user) use (&$uploadList) {
$this->userManager->callForSeenUsers(function (IUser $user) use (&$uploadList): void {
$userId = $user->getUID();
try {
\OC_Util::setupFS($userId);

3
core/BackgroundJobs/GenerateMetadataJob.php

@ -8,6 +8,7 @@ declare(strict_types=1);
namespace OC\Core\BackgroundJobs;
use OC\Files\Mount\MoveableMount;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\BackgroundJob\IJobList;
use OCP\BackgroundJob\TimedJob;
@ -83,7 +84,7 @@ class GenerateMetadataJob extends TimedJob {
private function scanFolder(Folder $folder): void {
// Do not scan share and other moveable mounts.
if ($folder->getMountPoint() instanceof \OC\Files\Mount\MoveableMount) {
if ($folder->getMountPoint() instanceof MoveableMount) {
return;
}

2
core/BackgroundJobs/LookupServerSendCheckBackgroundJob.php

@ -27,7 +27,7 @@ class LookupServerSendCheckBackgroundJob extends QueuedJob {
* @param array $argument
*/
public function run($argument): void {
$this->userManager->callForSeenUsers(function (IUser $user) {
$this->userManager->callForSeenUsers(function (IUser $user): void {
// If the user data was not updated yet (check if LUS is enabled and if then update on LUS or delete on LUS)
// then we need to flag the user data to be checked
if ($this->config->getUserValue($user->getUID(), 'lookup_server_connector', 'dataSend', '') === '') {

3
core/Command/App/Update.php

@ -9,6 +9,7 @@ declare(strict_types=1);
namespace OC\Core\Command\App;
use OC\Installer;
use OCP\App\AppPathNotFoundException;
use OCP\App\IAppManager;
use Psr\Log\LoggerInterface;
use Symfony\Component\Console\Command\Command;
@ -64,7 +65,7 @@ class Update extends Command {
$apps = [$singleAppId];
try {
$this->manager->getAppPath($singleAppId);
} catch (\OCP\App\AppPathNotFoundException $e) {
} catch (AppPathNotFoundException $e) {
$output->writeln($singleAppId . ' not installed');
return 1;
}

8
core/Command/Background/Job.php

@ -10,6 +10,8 @@ namespace OC\Core\Command\Background;
use OCP\BackgroundJob\IJob;
use OCP\BackgroundJob\IJobList;
use OCP\BackgroundJob\QueuedJob;
use OCP\BackgroundJob\TimedJob;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
@ -75,7 +77,7 @@ class Job extends Command {
$output->writeln('<info>Job executed!</info>');
$output->writeln('');
if ($job instanceof \OCP\BackgroundJob\TimedJob) {
if ($job instanceof TimedJob) {
$this->printJobInfo($jobId, $job, $output);
}
} else {
@ -99,10 +101,10 @@ class Job extends Command {
$output->writeln('Job class: ' . get_class($job));
$output->writeln('Arguments: ' . json_encode($job->getArgument()));
$isTimedJob = $job instanceof \OCP\BackgroundJob\TimedJob;
$isTimedJob = $job instanceof TimedJob;
if ($isTimedJob) {
$output->writeln('Type: timed');
} elseif ($job instanceof \OCP\BackgroundJob\QueuedJob) {
} elseif ($job instanceof QueuedJob) {
$output->writeln('Type: queued');
} else {
$output->writeln('Type: job');

9
core/Command/Background/JobBase.php

@ -10,12 +10,15 @@ declare(strict_types=1);
namespace OC\Core\Command\Background;
use OC\Core\Command\Base;
use OCP\BackgroundJob\IJob;
use OCP\BackgroundJob\IJobList;
use OCP\BackgroundJob\QueuedJob;
use OCP\BackgroundJob\TimedJob;
use Psr\Log\LoggerInterface;
use Symfony\Component\Console\Output\OutputInterface;
abstract class JobBase extends \OC\Core\Command\Base {
abstract class JobBase extends Base {
public function __construct(
protected IJobList $jobList,
@ -41,10 +44,10 @@ abstract class JobBase extends \OC\Core\Command\Base {
$output->writeln('Job class: ' . get_class($job));
$output->writeln('Arguments: ' . json_encode($job->getArgument()));
$isTimedJob = $job instanceof \OCP\BackgroundJob\TimedJob;
$isTimedJob = $job instanceof TimedJob;
if ($isTimedJob) {
$output->writeln('Type: timed');
} elseif ($job instanceof \OCP\BackgroundJob\QueuedJob) {
} elseif ($job instanceof QueuedJob) {
$output->writeln('Type: queued');
} else {
$output->writeln('Type: job');

13
core/Command/Broadcast/Test.php

@ -44,16 +44,11 @@ class Test extends Command {
$uid = $input->getArgument('uid');
$event = new class($name, $uid) extends ABroadcastedEvent {
/** @var string */
private $name;
/** @var string */
private $uid;
public function __construct(string $name,
string $uid) {
public function __construct(
private string $name,
private string $uid,
) {
parent::__construct();
$this->name = $name;
$this->uid = $uid;
}
public function broadcastAs(): string {

6
core/Command/Db/ConvertType.php

@ -13,9 +13,11 @@ use Doctrine\DBAL\Schema\Table;
use OC\DB\Connection;
use OC\DB\ConnectionFactory;
use OC\DB\MigrationService;
use OC\DB\PgSqlTools;
use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\DB\Types;
use OCP\IConfig;
use OCP\Server;
use Stecman\Component\Symfony\Console\BashCompletion\Completion\CompletionAwareInterface;
use Stecman\Component\Symfony\Console\BashCompletion\CompletionContext;
use Symfony\Component\Console\Command\Command;
@ -159,7 +161,7 @@ class ConvertType extends Command implements CompletionAwareInterface {
$this->readPassword($input, $output);
/** @var Connection $fromDB */
$fromDB = \OC::$server->get(Connection::class);
$fromDB = Server::get(Connection::class);
$toDB = $this->getToDBConnection($input, $output);
if ($input->getOption('clear-schema')) {
@ -401,7 +403,7 @@ class ConvertType extends Command implements CompletionAwareInterface {
$this->copyTable($fromDB, $toDB, $schema->getTable($table), $input, $output);
}
if ($input->getArgument('type') === 'pgsql') {
$tools = new \OC\DB\PgSqlTools($this->config);
$tools = new PgSqlTools($this->config);
$tools->resynchronizeDatabaseSequences($toDB);
}
// save new database config

2
core/Command/Encryption/ListModules.php

@ -57,7 +57,7 @@ class ListModules extends Base {
*/
protected function writeModuleList(InputInterface $input, OutputInterface $output, $items) {
if ($input->getOption('output') === self::OUTPUT_FORMAT_PLAIN) {
array_walk($items, function (&$item) {
array_walk($items, function (&$item): void {
if (!$item['default']) {
$item = $item['displayName'];
} else {

3
core/Command/Info/File.php

@ -9,6 +9,7 @@ namespace OC\Core\Command\Info;
use OC\Files\ObjectStore\ObjectStoreStorage;
use OC\Files\Storage\Wrapper\Encryption;
use OC\Files\Storage\Wrapper\Wrapper;
use OC\Files\View;
use OCA\Files_External\Config\ExternalMountPoint;
use OCA\GroupFolders\Mount\GroupMountPoint;
@ -176,7 +177,7 @@ class File extends Command {
if ($input->getOption('storage-tree')) {
$storageTmp = $storage;
$storageClass = get_class($storageTmp) . ' (cache:' . get_class($storageTmp->getCache()) . ')';
while ($storageTmp instanceof \OC\Files\Storage\Wrapper\Wrapper) {
while ($storageTmp instanceof Wrapper) {
$storageTmp = $storageTmp->getWrapperStorage();
$storageClass .= "\n\t" . '> ' . get_class($storageTmp) . ' (cache:' . get_class($storageTmp->getCache()) . ')';
}

6
core/Command/Info/FileUtils.php

@ -8,6 +8,7 @@ declare(strict_types=1);
namespace OC\Core\Command\Info;
use OC\User\NoUserException;
use OCA\Circles\MountManager\CircleMount;
use OCA\Files_External\Config\ExternalMountPoint;
use OCA\Files_Sharing\SharedMount;
@ -21,6 +22,7 @@ use OCP\Files\IRootFolder;
use OCP\Files\Mount\IMountPoint;
use OCP\Files\Node;
use OCP\Files\NotFoundException;
use OCP\Files\NotPermittedException;
use OCP\Share\IShare;
use OCP\Util;
use Symfony\Component\Console\Output\OutputInterface;
@ -35,8 +37,8 @@ class FileUtils {
/**
* @param FileInfo $file
* @return array<string, Node[]>
* @throws \OCP\Files\NotPermittedException
* @throws \OC\User\NoUserException
* @throws NotPermittedException
* @throws NoUserException
*/
public function getFilesByUser(FileInfo $file): array {
$id = $file->getId();

5
core/Command/Log/File.php

@ -8,6 +8,7 @@
namespace OC\Core\Command\Log;
use OCP\IConfig;
use OCP\Util;
use Stecman\Component\Symfony\Console\BashCompletion\Completion;
use Stecman\Component\Symfony\Console\BashCompletion\Completion\ShellPathCompletion;
@ -61,7 +62,7 @@ class File extends Command implements Completion\CompletionAwareInterface {
}
if (($rotateSize = $input->getOption('rotate-size')) !== null) {
$rotateSize = \OCP\Util::computerFileSize($rotateSize);
$rotateSize = Util::computerFileSize($rotateSize);
$this->validateRotateSize($rotateSize);
$toBeSet['log_rotate_size'] = $rotateSize;
}
@ -87,7 +88,7 @@ class File extends Command implements Completion\CompletionAwareInterface {
$rotateSize = $this->config->getSystemValue('log_rotate_size', 100 * 1024 * 1024);
if ($rotateSize) {
$rotateString = \OCP\Util::humanFileSize($rotateSize);
$rotateString = Util::humanFileSize($rotateSize);
} else {
$rotateString = 'disabled';
}

3
core/Command/Maintenance/Install.php

@ -15,6 +15,7 @@ use OC\Console\TimestampFormatter;
use OC\Migration\ConsoleOutput;
use OC\Setup;
use OC\SystemConfig;
use OCP\Server;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Helper\QuestionHelper;
use Symfony\Component\Console\Input\InputInterface;
@ -51,7 +52,7 @@ class Install extends Command {
protected function execute(InputInterface $input, OutputInterface $output): int {
// validate the environment
$setupHelper = \OCP\Server::get(\OC\Setup::class);
$setupHelper = Server::get(Setup::class);
$sysInfo = $setupHelper->getSystemInfo(true);
$errors = $sysInfo['errors'];
if (count($errors) > 0) {

3
core/Command/Maintenance/UpdateHtaccess.php

@ -7,6 +7,7 @@
*/
namespace OC\Core\Command\Maintenance;
use OC\Setup;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
@ -19,7 +20,7 @@ class UpdateHtaccess extends Command {
}
protected function execute(InputInterface $input, OutputInterface $output): int {
if (\OC\Setup::updateHtaccess()) {
if (Setup::updateHtaccess()) {
$output->writeln('.htaccess has been updated');
return 0;
} else {

2
core/Command/Preview/Repair.php

@ -86,7 +86,7 @@ class Repair extends Command {
$output->writeln('');
$output->writeln('Fetching previews that need to be migrated …');
/** @var \OCP\Files\Folder $currentPreviewFolder */
/** @var Folder $currentPreviewFolder */
$currentPreviewFolder = $this->rootFolder->get("appdata_$instanceId/preview");
$directoryListing = $currentPreviewFolder->getDirectoryListing();

37
core/Command/Upgrade.php

@ -21,6 +21,7 @@ use OCP\EventDispatcher\Event;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\IConfig;
use OCP\IURLGenerator;
use OCP\Server;
use OCP\Util;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Helper\ProgressBar;
@ -63,11 +64,11 @@ class Upgrade extends Command {
}
$self = $this;
$updater = \OCP\Server::get(Updater::class);
$updater = Server::get(Updater::class);
$incompatibleOverwrites = $this->config->getSystemValue('app_install_overwrite', []);
/** @var IEventDispatcher $dispatcher */
$dispatcher = \OC::$server->get(IEventDispatcher::class);
$dispatcher = Server::get(IEventDispatcher::class);
$progress = new ProgressBar($output);
$progress->setFormat(" %message%\n %current%/%max% [%bar%] %percent:3s%%");
$listener = function (MigratorExecuteSqlEvent $event) use ($progress, $output): void {
@ -132,17 +133,17 @@ class Upgrade extends Command {
$dispatcher->addListener(RepairErrorEvent::class, $repairListener);
$updater->listen('\OC\Updater', 'maintenanceEnabled', function () use ($output) {
$updater->listen('\OC\Updater', 'maintenanceEnabled', function () use ($output): void {
$output->writeln('<info>Turned on maintenance mode</info>');
});
$updater->listen('\OC\Updater', 'maintenanceDisabled', function () use ($output) {
$updater->listen('\OC\Updater', 'maintenanceDisabled', function () use ($output): void {
$output->writeln('<info>Turned off maintenance mode</info>');
});
$updater->listen('\OC\Updater', 'maintenanceActive', function () use ($output) {
$updater->listen('\OC\Updater', 'maintenanceActive', function () use ($output): void {
$output->writeln('<info>Maintenance mode is kept active</info>');
});
$updater->listen('\OC\Updater', 'updateEnd',
function ($success) use ($output, $self) {
function ($success) use ($output, $self): void {
if ($success) {
$message = '<info>Update successful</info>';
} else {
@ -150,42 +151,42 @@ class Upgrade extends Command {
}
$output->writeln($message);
});
$updater->listen('\OC\Updater', 'dbUpgradeBefore', function () use ($output) {
$updater->listen('\OC\Updater', 'dbUpgradeBefore', function () use ($output): void {
$output->writeln('<info>Updating database schema</info>');
});
$updater->listen('\OC\Updater', 'dbUpgrade', function () use ($output) {
$updater->listen('\OC\Updater', 'dbUpgrade', function () use ($output): void {
$output->writeln('<info>Updated database</info>');
});
$updater->listen('\OC\Updater', 'incompatibleAppDisabled', function ($app) use ($output, &$incompatibleOverwrites) {
$updater->listen('\OC\Updater', 'incompatibleAppDisabled', function ($app) use ($output, &$incompatibleOverwrites): void {
if (!in_array($app, $incompatibleOverwrites)) {
$output->writeln('<comment>Disabled incompatible app: ' . $app . '</comment>');
}
});
$updater->listen('\OC\Updater', 'upgradeAppStoreApp', function ($app) use ($output) {
$updater->listen('\OC\Updater', 'upgradeAppStoreApp', function ($app) use ($output): void {
$output->writeln('<info>Update app ' . $app . ' from App Store</info>');
});
$updater->listen('\OC\Updater', 'appSimulateUpdate', function ($app) use ($output) {
$updater->listen('\OC\Updater', 'appSimulateUpdate', function ($app) use ($output): void {
$output->writeln("<info>Checking whether the database schema for <$app> can be updated (this can take a long time depending on the database size)</info>");
});
$updater->listen('\OC\Updater', 'appUpgradeStarted', function ($app, $version) use ($output) {
$updater->listen('\OC\Updater', 'appUpgradeStarted', function ($app, $version) use ($output): void {
$output->writeln("<info>Updating <$app> ...</info>");
});
$updater->listen('\OC\Updater', 'appUpgrade', function ($app, $version) use ($output) {
$updater->listen('\OC\Updater', 'appUpgrade', function ($app, $version) use ($output): void {
$output->writeln("<info>Updated <$app> to $version</info>");
});
$updater->listen('\OC\Updater', 'failure', function ($message) use ($output, $self) {
$updater->listen('\OC\Updater', 'failure', function ($message) use ($output, $self): void {
$output->writeln("<error>$message</error>");
});
$updater->listen('\OC\Updater', 'setDebugLogLevel', function ($logLevel, $logLevelName) use ($output) {
$updater->listen('\OC\Updater', 'setDebugLogLevel', function ($logLevel, $logLevelName) use ($output): void {
$output->writeln('<info>Setting log level to debug</info>');
});
$updater->listen('\OC\Updater', 'resetLogLevel', function ($logLevel, $logLevelName) use ($output) {
$updater->listen('\OC\Updater', 'resetLogLevel', function ($logLevel, $logLevelName) use ($output): void {
$output->writeln('<info>Resetting log level</info>');
});
$updater->listen('\OC\Updater', 'startCheckCodeIntegrity', function () use ($output) {
$updater->listen('\OC\Updater', 'startCheckCodeIntegrity', function () use ($output): void {
$output->writeln('<info>Starting code integrity check...</info>');
});
$updater->listen('\OC\Updater', 'finishedCheckCodeIntegrity', function () use ($output) {
$updater->listen('\OC\Updater', 'finishedCheckCodeIntegrity', function () use ($output): void {
$output->writeln('<info>Finished code integrity check</info>');
});

3
core/Command/User/Info.php

@ -6,6 +6,7 @@
namespace OC\Core\Command\User;
use OC\Core\Command\Base;
use OCP\Files\NotFoundException;
use OCP\IGroupManager;
use OCP\IUser;
use OCP\IUserManager;
@ -84,7 +85,7 @@ class Info extends Base {
\OC_Util::setupFS($user->getUID());
try {
$storage = \OC_Helper::getStorageInfo('/');
} catch (\OCP\Files\NotFoundException $e) {
} catch (NotFoundException $e) {
return [];
}
return [

2
core/Command/User/LastSeen.php

@ -68,7 +68,7 @@ class LastSeen extends Base {
return 1;
}
$this->userManager->callForAllUsers(static function (IUser $user) use ($output) {
$this->userManager->callForAllUsers(static function (IUser $user) use ($output): void {
$lastLogin = $user->getLastLogin();
if ($lastLogin === 0) {
$output->writeln($user->getUID() . ' has never logged in.');

9
core/Command/User/SyncAccountDataCommand.php

@ -16,15 +16,10 @@ use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
class SyncAccountDataCommand extends Base {
protected IUserManager $userManager;
protected IAccountManager $accountManager;
public function __construct(
IUserManager $userManager,
IAccountManager $accountManager,
protected IUserManager $userManager,
protected IAccountManager $accountManager,
) {
$this->userManager = $userManager;
$this->accountManager = $accountManager;
parent::__construct();
}

13
core/Command/User/Welcome.php

@ -15,24 +15,15 @@ use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
class Welcome extends Base {
/** @var IUserManager */
protected $userManager;
/** @var NewUserMailHelper */
private $newUserMailHelper;
/**
* @param IUserManager $userManager
* @param NewUserMailHelper $newUserMailHelper
*/
public function __construct(
IUserManager $userManager,
NewUserMailHelper $newUserMailHelper,
protected IUserManager $userManager,
private NewUserMailHelper $newUserMailHelper,
) {
parent::__construct();
$this->userManager = $userManager;
$this->newUserMailHelper = $newUserMailHelper;
}
/**

3
core/Controller/AppPasswordController.php

@ -20,6 +20,7 @@ use OCP\AppFramework\Http\Attribute\PasswordConfirmationRequired;
use OCP\AppFramework\Http\Attribute\UseSession;
use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\OCS\OCSForbiddenException;
use OCP\AppFramework\OCSController;
use OCP\Authentication\Exceptions\CredentialsUnavailableException;
use OCP\Authentication\Exceptions\InvalidTokenException;
use OCP\Authentication\Exceptions\PasswordUnavailableException;
@ -31,7 +32,7 @@ use OCP\IUserManager;
use OCP\Security\Bruteforce\IThrottler;
use OCP\Security\ISecureRandom;
class AppPasswordController extends \OCP\AppFramework\OCSController {
class AppPasswordController extends OCSController {
public function __construct(
string $appName,
IRequest $request,

13
core/Controller/AvatarController.php

@ -8,6 +8,7 @@
namespace OC\Core\Controller;
use OC\AppFramework\Utility\TimeFactory;
use OC\NotSquareException;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\Attribute\FrontpageRoute;
@ -21,9 +22,11 @@ use OCP\AppFramework\Http\JSONResponse;
use OCP\AppFramework\Http\Response;
use OCP\Files\File;
use OCP\Files\IRootFolder;
use OCP\Files\NotPermittedException;
use OCP\IAvatarManager;
use OCP\ICache;
use OCP\IL10N;
use OCP\Image;
use OCP\IRequest;
use OCP\IUserManager;
use Psr\Log\LoggerInterface;
@ -182,7 +185,7 @@ class AvatarController extends Controller {
try {
$content = $node->getContent();
} catch (\OCP\Files\NotPermittedException $e) {
} catch (NotPermittedException $e) {
return new JSONResponse(
['data' => ['message' => $this->l10n->t('The selected file cannot be read.')]],
Http::STATUS_BAD_REQUEST
@ -229,7 +232,7 @@ class AvatarController extends Controller {
}
try {
$image = new \OCP\Image();
$image = new Image();
$image->loadFromData($content);
$image->readExif($content);
$image->fixOrientation();
@ -300,7 +303,7 @@ class AvatarController extends Controller {
Http::STATUS_NOT_FOUND);
}
$image = new \OCP\Image();
$image = new Image();
$image->loadFromData($tmpAvatar);
$resp = new DataDisplayResponse(
@ -335,7 +338,7 @@ class AvatarController extends Controller {
Http::STATUS_BAD_REQUEST);
}
$image = new \OCP\Image();
$image = new Image();
$image->loadFromData($tmpAvatar);
$image->crop($crop['x'], $crop['y'], (int)round($crop['w']), (int)round($crop['h']));
try {
@ -344,7 +347,7 @@ class AvatarController extends Controller {
// Clean up
$this->cache->remove('tmpAvatar');
return new JSONResponse(['status' => 'success']);
} catch (\OC\NotSquareException $e) {
} catch (NotSquareException $e) {
return new JSONResponse(['data' => ['message' => $this->l10n->t('Crop is not square')]],
Http::STATUS_BAD_REQUEST);
} catch (\Exception $e) {

10
core/Controller/ClientFlowLoginController.php

@ -19,6 +19,8 @@ use OCP\AppFramework\Http\Attribute\NoCSRFRequired;
use OCP\AppFramework\Http\Attribute\OpenAPI;
use OCP\AppFramework\Http\Attribute\PublicPage;
use OCP\AppFramework\Http\Attribute\UseSession;
use OCP\AppFramework\Http\ContentSecurityPolicy;
use OCP\AppFramework\Http\RedirectResponse;
use OCP\AppFramework\Http\Response;
use OCP\AppFramework\Http\StandaloneTemplateResponse;
use OCP\AppFramework\Utility\ITimeFactory;
@ -124,7 +126,7 @@ class ClientFlowLoginController extends Controller {
);
$this->session->set(self::STATE_NAME, $stateToken);
$csp = new Http\ContentSecurityPolicy();
$csp = new ContentSecurityPolicy();
if ($client) {
$csp->addAllowedFormActionDomain($client->getRedirectUri());
} else {
@ -177,7 +179,7 @@ class ClientFlowLoginController extends Controller {
$clientName = $client->getName();
}
$csp = new Http\ContentSecurityPolicy();
$csp = new ContentSecurityPolicy();
if ($client) {
$csp->addAllowedFormActionDomain($client->getRedirectUri());
} else {
@ -313,7 +315,7 @@ class ClientFlowLoginController extends Controller {
new AppPasswordCreatedEvent($generatedToken)
);
return new Http\RedirectResponse($redirectUri);
return new RedirectResponse($redirectUri);
}
#[PublicPage]
@ -342,7 +344,7 @@ class ClientFlowLoginController extends Controller {
}
$redirectUri = 'nc://login/server:' . $this->getServerPath() . '&user:' . urlencode($user) . '&password:' . urlencode($password);
return new Http\RedirectResponse($redirectUri);
return new RedirectResponse($redirectUri);
}
private function getServerPath(): string {

3
core/Controller/ClientFlowLoginV2Controller.php

@ -34,6 +34,7 @@ use OCP\IURLGenerator;
use OCP\IUser;
use OCP\IUserSession;
use OCP\Security\ISecureRandom;
use OCP\Server;
/**
* @psalm-import-type CoreLoginFlowV2Credentials from ResponseDefinitions
@ -204,7 +205,7 @@ class ClientFlowLoginV2Controller extends Controller {
$this->session->remove(self::STATE_NAME);
try {
$token = \OC::$server->get(\OC\Authentication\Token\IProvider::class)->getToken($password);
$token = Server::get(\OC\Authentication\Token\IProvider::class)->getToken($password);
if ($token->getLoginName() !== $user) {
throw new InvalidTokenException('login name does not match');
}

3
core/Controller/ErrorController.php

@ -9,6 +9,7 @@ declare(strict_types=1);
namespace OC\Core\Controller;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\Attribute\FrontpageRoute;
use OCP\AppFramework\Http\Attribute\NoCSRFRequired;
@ -17,7 +18,7 @@ use OCP\AppFramework\Http\Attribute\PublicPage;
use OCP\AppFramework\Http\TemplateResponse;
#[OpenAPI(scope: OpenAPI::SCOPE_IGNORE)]
class ErrorController extends \OCP\AppFramework\Controller {
class ErrorController extends Controller {
#[PublicPage]
#[NoCSRFRequired]
#[FrontpageRoute(verb: 'GET', url: 'error/403')]

2
core/Controller/GuestAvatarController.php

@ -76,7 +76,7 @@ class GuestAvatarController extends Controller {
$this->logger->error('error while creating guest avatar', [
'err' => $e,
]);
$resp = new Http\Response();
$resp = new Response();
$resp->setStatus(Http::STATUS_INTERNAL_SERVER_ERROR);
return $resp;
}

3
core/Controller/HoverCardController.php

@ -13,6 +13,7 @@ use OCP\AppFramework\Http;
use OCP\AppFramework\Http\Attribute\ApiRoute;
use OCP\AppFramework\Http\Attribute\NoAdminRequired;
use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\OCSController;
use OCP\IRequest;
use OCP\IUserSession;
use OCP\Share\IShare;
@ -20,7 +21,7 @@ use OCP\Share\IShare;
/**
* @psalm-import-type CoreContactsAction from ResponseDefinitions
*/
class HoverCardController extends \OCP\AppFramework\OCSController {
class HoverCardController extends OCSController {
public function __construct(
IRequest $request,
private IUserSession $userSession,

6
core/Controller/LoginController.php

@ -29,6 +29,7 @@ use OCP\AppFramework\Http\Attribute\PublicPage;
use OCP\AppFramework\Http\Attribute\UseSession;
use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\Http\RedirectResponse;
use OCP\AppFramework\Http\Response;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\AppFramework\Services\IInitialState;
use OCP\Defaults;
@ -42,6 +43,7 @@ use OCP\IUserManager;
use OCP\Notification\IManager;
use OCP\Security\Bruteforce\IThrottler;
use OCP\Security\ITrustedDomainHelper;
use OCP\Server;
use OCP\Util;
class LoginController extends Controller {
@ -111,7 +113,7 @@ class LoginController extends Controller {
#[UseSession]
#[OpenAPI(scope: OpenAPI::SCOPE_IGNORE)]
#[FrontpageRoute(verb: 'GET', url: '/login')]
public function showLoginForm(?string $user = null, ?string $redirect_url = null): Http\Response {
public function showLoginForm(?string $user = null, ?string $redirect_url = null): Response {
if ($this->userSession->isLoggedIn()) {
return new RedirectResponse($this->urlGenerator->linkToDefaultPageUrl());
}
@ -224,7 +226,7 @@ class LoginController extends Controller {
// check if user_ldap is enabled, and the required classes exist
if ($this->appManager->isAppLoaded('user_ldap')
&& class_exists(Helper::class)) {
$helper = \OCP\Server::get(Helper::class);
$helper = Server::get(Helper::class);
$allPrefixes = $helper->getServerConfigurationPrefixes();
// check each LDAP server the user is connected too
foreach ($allPrefixes as $prefix) {

15
core/Controller/LostController.php

@ -14,6 +14,7 @@ use OC\Core\Events\PasswordResetEvent;
use OC\Core\Exception\ResetPasswordException;
use OC\Security\RateLimiting\Exception\RateLimitExceededException;
use OC\Security\RateLimiting\Limiter;
use OC\User\Session;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http\Attribute\AnonRateLimit;
use OCP\AppFramework\Http\Attribute\BruteForceProtection;
@ -36,8 +37,11 @@ use OCP\IURLGenerator;
use OCP\IUser;
use OCP\IUserManager;
use OCP\Mail\IMailer;
use OCP\PreConditionNotMetException;
use OCP\Security\VerificationToken\InvalidTokenException;
use OCP\Security\VerificationToken\IVerificationToken;
use OCP\Server;
use OCP\Util;
use Psr\Log\LoggerInterface;
use function array_filter;
use function count;
@ -52,8 +56,6 @@ use function reset;
*/
#[OpenAPI(scope: OpenAPI::SCOPE_IGNORE)]
class LostController extends Controller {
protected string $from;
public function __construct(
string $appName,
IRequest $request,
@ -62,7 +64,7 @@ class LostController extends Controller {
private Defaults $defaults,
private IL10N $l10n,
private IConfig $config,
string $defaultMailAddress,
protected string $from,
private IManager $encryptionManager,
private IMailer $mailer,
private LoggerInterface $logger,
@ -73,7 +75,6 @@ class LostController extends Controller {
private Limiter $limiter,
) {
parent::__construct($appName, $request);
$this->from = $defaultMailAddress;
}
/**
@ -158,7 +159,7 @@ class LostController extends Controller {
return new JSONResponse($this->error($this->l10n->t('Unsupported email length (>255)')));
}
\OCP\Util::emitHook(
Util::emitHook(
'\OCA\Files_Sharing\API\Server2Server',
'preLoginNameUsedAsUserName',
['uid' => &$user]
@ -217,7 +218,7 @@ class LostController extends Controller {
$this->twoFactorManager->clearTwoFactorPending($userId);
$this->config->deleteUserValue($userId, 'core', 'lostpassword');
@\OC::$server->getUserSession()->unsetMagicInCookie();
@Server::get(Session::class)->unsetMagicInCookie();
} catch (HintException $e) {
$response = new JSONResponse($this->error($e->getHint()));
$response->throttle();
@ -233,7 +234,7 @@ class LostController extends Controller {
/**
* @throws ResetPasswordException
* @throws \OCP\PreConditionNotMetException
* @throws PreConditionNotMetException
*/
protected function sendEmail(string $input): void {
$user = $this->findUserByIdOrMail($input);

3
core/Controller/OCMController.php

@ -10,6 +10,7 @@ declare(strict_types=1);
namespace OC\Core\Controller;
use Exception;
use OCA\CloudFederationAPI\Capabilities;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\Attribute\FrontpageRoute;
@ -58,7 +59,7 @@ class OCMController extends Controller {
$cap = Server::get(
$this->appConfig->getValueString(
'core', 'ocm_providers',
\OCA\CloudFederationAPI\Capabilities::class,
Capabilities::class,
lazy: true
)
);

3
core/Controller/OCSController.php

@ -17,6 +17,7 @@ use OCP\IRequest;
use OCP\IUserManager;
use OCP\IUserSession;
use OCP\ServerVersion;
use OCP\Util;
class OCSController extends \OCP\AppFramework\OCSController {
public function __construct(
@ -63,7 +64,7 @@ class OCSController extends \OCP\AppFramework\OCSController {
'micro' => $this->serverVersion->getPatchVersion(),
'string' => $this->serverVersion->getVersionString(),
'edition' => '',
'extendedSupport' => \OCP\Util::hasExtendedSupport()
'extendedSupport' => Util::hasExtendedSupport()
];
if ($this->userSession->isLoggedIn()) {

5
core/Controller/PreviewController.php

@ -18,6 +18,7 @@ use OCP\AppFramework\Http\Attribute\PublicPage;
use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\Http\FileDisplayResponse;
use OCP\AppFramework\Http\RedirectResponse;
use OCP\AppFramework\Http\Response;
use OCP\Files\File;
use OCP\Files\IRootFolder;
use OCP\Files\Node;
@ -68,7 +69,7 @@ class PreviewController extends Controller {
bool $a = false,
bool $forceIcon = true,
string $mode = 'fill',
bool $mimeFallback = false): Http\Response {
bool $mimeFallback = false): Response {
if ($file === '' || $x === 0 || $y === 0) {
return new DataResponse([], Http::STATUS_BAD_REQUEST);
}
@ -137,7 +138,7 @@ class PreviewController extends Controller {
bool $a,
bool $forceIcon,
string $mode,
bool $mimeFallback = false) : Http\Response {
bool $mimeFallback = false) : Response {
if (!($node instanceof File) || (!$forceIcon && !$this->preview->isAvailable($node))) {
return new DataResponse([], Http::STATUS_NOT_FOUND);
}

3
core/Controller/ReferenceApiController.php

@ -15,6 +15,7 @@ use OCP\AppFramework\Http\Attribute\ApiRoute;
use OCP\AppFramework\Http\Attribute\NoAdminRequired;
use OCP\AppFramework\Http\Attribute\PublicPage;
use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\OCSController;
use OCP\Collaboration\Reference\IDiscoverableReferenceProvider;
use OCP\Collaboration\Reference\IReferenceManager;
use OCP\Collaboration\Reference\Reference;
@ -24,7 +25,7 @@ use OCP\IRequest;
* @psalm-import-type CoreReference from ResponseDefinitions
* @psalm-import-type CoreReferenceProvider from ResponseDefinitions
*/
class ReferenceApiController extends \OCP\AppFramework\OCSController {
class ReferenceApiController extends OCSController {
private const LIMIT_MAX = 15;
public function __construct(

6
core/Controller/SetupController.php

@ -7,9 +7,11 @@
*/
namespace OC\Core\Controller;
use OC\IntegrityCheck\Checker;
use OC\Setup;
use OCP\IInitialStateService;
use OCP\IURLGenerator;
use OCP\Server;
use OCP\Template\ITemplateManager;
use OCP\Util;
use Psr\Log\LoggerInterface;
@ -104,13 +106,13 @@ class SetupController {
if (file_exists($this->autoConfigFile)) {
unlink($this->autoConfigFile);
}
\OC::$server->getIntegrityCodeChecker()->runInstanceVerification();
Server::get(Checker::class)->runInstanceVerification();
if ($this->setupHelper->shouldRemoveCanInstallFile()) {
$this->templateManager->printGuestPage('', 'installation_incomplete');
}
header('Location: ' . \OC::$server->getURLGenerator()->getAbsoluteURL('index.php/core/apps/recommended'));
header('Location: ' . Server::get(IURLGenerator::class)->getAbsoluteURL('index.php/core/apps/recommended'));
exit();
}

14
core/Controller/TaskProcessingApiController.php

@ -17,10 +17,12 @@ use OCP\AppFramework\Http\Attribute\AnonRateLimit;
use OCP\AppFramework\Http\Attribute\ApiRoute;
use OCP\AppFramework\Http\Attribute\ExAppRequired;
use OCP\AppFramework\Http\Attribute\NoAdminRequired;
use OCP\AppFramework\Http\Attribute\NoCSRFRequired;
use OCP\AppFramework\Http\Attribute\PublicPage;
use OCP\AppFramework\Http\Attribute\UserRateLimit;
use OCP\AppFramework\Http\DataDownloadResponse;
use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\OCSController;
use OCP\Files\File;
use OCP\Files\GenericFileException;
use OCP\Files\IAppData;
@ -45,7 +47,7 @@ use stdClass;
* @psalm-import-type CoreTaskProcessingTask from ResponseDefinitions
* @psalm-import-type CoreTaskProcessingTaskType from ResponseDefinitions
*/
class TaskProcessingApiController extends \OCP\AppFramework\OCSController {
class TaskProcessingApiController extends OCSController {
public function __construct(
string $appName,
IRequest $request,
@ -306,9 +308,9 @@ class TaskProcessingApiController extends \OCP\AppFramework\OCSController {
* 404: Task or file not found
*/
#[NoAdminRequired]
#[Http\Attribute\NoCSRFRequired]
#[NoCSRFRequired]
#[ApiRoute(verb: 'GET', url: '/tasks/{taskId}/file/{fileId}', root: '/taskprocessing')]
public function getFileContents(int $taskId, int $fileId): Http\DataDownloadResponse|DataResponse {
public function getFileContents(int $taskId, int $fileId): DataDownloadResponse|DataResponse {
try {
$task = $this->taskProcessingManager->getUserTask($taskId, $this->userId);
return $this->getFileContentsInternal($task, $fileId);
@ -331,7 +333,7 @@ class TaskProcessingApiController extends \OCP\AppFramework\OCSController {
*/
#[ExAppRequired]
#[ApiRoute(verb: 'GET', url: '/tasks_provider/{taskId}/file/{fileId}', root: '/taskprocessing')]
public function getFileContentsExApp(int $taskId, int $fileId): Http\DataDownloadResponse|DataResponse {
public function getFileContentsExApp(int $taskId, int $fileId): DataDownloadResponse|DataResponse {
try {
$task = $this->taskProcessingManager->getTask($taskId);
return $this->getFileContentsInternal($task, $fileId);
@ -384,7 +386,7 @@ class TaskProcessingApiController extends \OCP\AppFramework\OCSController {
*
* @return DataDownloadResponse<Http::STATUS_OK, string, array{}>|DataResponse<Http::STATUS_INTERNAL_SERVER_ERROR|Http::STATUS_NOT_FOUND, array{message: string}, array{}>
*/
private function getFileContentsInternal(Task $task, int $fileId): Http\DataDownloadResponse|DataResponse {
private function getFileContentsInternal(Task $task, int $fileId): DataDownloadResponse|DataResponse {
$ids = $this->extractFileIdsFromTask($task);
if (!in_array($fileId, $ids)) {
return new DataResponse(['message' => $this->l->t('Not found')], Http::STATUS_NOT_FOUND);
@ -401,7 +403,7 @@ class TaskProcessingApiController extends \OCP\AppFramework\OCSController {
} elseif (!$node instanceof File) {
throw new NotFoundException('Node is not a file');
}
return new Http\DataDownloadResponse($node->getContent(), $node->getName(), $node->getMimeType());
return new DataDownloadResponse($node->getContent(), $node->getName(), $node->getMimeType());
}
/**

3
core/Controller/TeamsApiController.php

@ -13,6 +13,7 @@ use OCP\AppFramework\Http;
use OCP\AppFramework\Http\Attribute\ApiRoute;
use OCP\AppFramework\Http\Attribute\NoAdminRequired;
use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\OCSController;
use OCP\IRequest;
use OCP\Teams\ITeamManager;
use OCP\Teams\Team;
@ -22,7 +23,7 @@ use OCP\Teams\Team;
* @psalm-import-type CoreTeam from ResponseDefinitions
* @property $userId string
*/
class TeamsApiController extends \OCP\AppFramework\OCSController {
class TeamsApiController extends OCSController {
public function __construct(
string $appName,
IRequest $request,

3
core/Controller/TextProcessingApiController.php

@ -19,6 +19,7 @@ use OCP\AppFramework\Http\Attribute\NoAdminRequired;
use OCP\AppFramework\Http\Attribute\PublicPage;
use OCP\AppFramework\Http\Attribute\UserRateLimit;
use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\OCSController;
use OCP\Common\Exception\NotFoundException;
use OCP\DB\Exception;
use OCP\IL10N;
@ -36,7 +37,7 @@ use Psr\Log\LoggerInterface;
/**
* @psalm-import-type CoreTextProcessingTask from ResponseDefinitions
*/
class TextProcessingApiController extends \OCP\AppFramework\OCSController {
class TextProcessingApiController extends OCSController {
public function __construct(
string $appName,
IRequest $request,

3
core/Controller/TextToImageApiController.php

@ -21,6 +21,7 @@ use OCP\AppFramework\Http\Attribute\PublicPage;
use OCP\AppFramework\Http\Attribute\UserRateLimit;
use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\Http\FileDisplayResponse;
use OCP\AppFramework\OCSController;
use OCP\DB\Exception;
use OCP\Files\NotFoundException;
use OCP\IL10N;
@ -34,7 +35,7 @@ use OCP\TextToImage\Task;
/**
* @psalm-import-type CoreTextToImageTask from ResponseDefinitions
*/
class TextToImageApiController extends \OCP\AppFramework\OCSController {
class TextToImageApiController extends OCSController {
public function __construct(
string $appName,
IRequest $request,

3
core/Controller/TranslationApiController.php

@ -17,13 +17,14 @@ use OCP\AppFramework\Http\Attribute\ApiRoute;
use OCP\AppFramework\Http\Attribute\PublicPage;
use OCP\AppFramework\Http\Attribute\UserRateLimit;
use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\OCSController;
use OCP\IL10N;
use OCP\IRequest;
use OCP\PreConditionNotMetException;
use OCP\Translation\CouldNotTranslateException;
use OCP\Translation\ITranslationManager;
class TranslationApiController extends \OCP\AppFramework\OCSController {
class TranslationApiController extends OCSController {
public function __construct(
string $appName,
IRequest $request,

3
core/Controller/WhatsNewController.php

@ -19,6 +19,7 @@ use OCP\IRequest;
use OCP\IUserManager;
use OCP\IUserSession;
use OCP\L10N\IFactory;
use OCP\PreConditionNotMetException;
use OCP\ServerVersion;
class WhatsNewController extends OCSController {
@ -88,7 +89,7 @@ class WhatsNewController extends OCSController {
* @param string $version Version to dismiss the changes for
*
* @return DataResponse<Http::STATUS_OK, list<empty>, array{}>
* @throws \OCP\PreConditionNotMetException
* @throws PreConditionNotMetException
* @throws DoesNotExistException
*
* 200: Changes dismissed

3
core/Migrations/Version14000Date20180626223656.php

@ -6,10 +6,11 @@
namespace OC\Core\Migrations;
use OCP\DB\ISchemaWrapper;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;
class Version14000Date20180626223656 extends SimpleMigrationStep {
public function changeSchema(\OCP\Migration\IOutput $output, \Closure $schemaClosure, array $options) {
public function changeSchema(IOutput $output, \Closure $schemaClosure, array $options) {
/** @var ISchemaWrapper $schema */
$schema = $schemaClosure();
if (!$schema->hasTable('whats_new')) {

3
core/Migrations/Version14000Date20180712153140.php

@ -6,6 +6,7 @@
namespace OC\Core\Migrations;
use OCP\DB\ISchemaWrapper;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;
/**
@ -14,7 +15,7 @@ use OCP\Migration\SimpleMigrationStep;
* Class Version14000Date20180712153140
*/
class Version14000Date20180712153140 extends SimpleMigrationStep {
public function changeSchema(\OCP\Migration\IOutput $output, \Closure $schemaClosure, array $options) {
public function changeSchema(IOutput $output, \Closure $schemaClosure, array $options) {
/** @var ISchemaWrapper $schema */
$schema = $schemaClosure();

54
core/ajax/update.php

@ -6,6 +6,8 @@
* SPDX-License-Identifier: AGPL-3.0-only
*/
use OC\DB\MigratorExecuteSqlEvent;
use OC\Installer;
use OC\IntegrityCheck\Checker;
use OC\Repair\Events\RepairAdvanceEvent;
use OC\Repair\Events\RepairErrorEvent;
use OC\Repair\Events\RepairFinishEvent;
@ -13,6 +15,8 @@ use OC\Repair\Events\RepairInfoEvent;
use OC\Repair\Events\RepairStartEvent;
use OC\Repair\Events\RepairStepEvent;
use OC\Repair\Events\RepairWarningEvent;
use OC\SystemConfig;
use OC\Updater;
use OCP\EventDispatcher\Event;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\IAppConfig;
@ -22,6 +26,8 @@ use OCP\IEventSourceFactory;
use OCP\IL10N;
use OCP\L10N\IFactory;
use OCP\Server;
use OCP\ServerVersion;
use OCP\Util;
use Psr\Log\LoggerInterface;
if (!str_contains(@ini_get('disable_functions'), 'set_time_limit')) {
@ -30,10 +36,10 @@ if (!str_contains(@ini_get('disable_functions'), 'set_time_limit')) {
require_once '../../lib/base.php';
/** @var \OCP\IL10N $l */
$l = \OC::$server->get(IFactory::class)->get('core');
/** @var IL10N $l */
$l = Server::get(IFactory::class)->get('core');
$eventSource = \OC::$server->get(IEventSourceFactory::class)->create();
$eventSource = Server::get(IEventSourceFactory::class)->create();
// need to send an initial message to force-init the event source,
// which will then trigger its own CSRF check and produces its own CSRF error
// message
@ -77,8 +83,8 @@ class FeedBackHandler {
}
}
if (\OCP\Util::needUpgrade()) {
$config = \OC::$server->getSystemConfig();
if (Util::needUpgrade()) {
$config = Server::get(SystemConfig::class);
if ($config->getValue('upgrade.disable-web', false)) {
$eventSource->send('failure', $l->t('Please use the command line updater because updating via browser is disabled in your config.php.'));
$eventSource->close();
@ -90,19 +96,19 @@ if (\OCP\Util::needUpgrade()) {
\OC_User::setIncognitoMode(true);
$config = Server::get(IConfig::class);
$updater = new \OC\Updater(
Server::get(\OCP\ServerVersion::class),
$updater = new Updater(
Server::get(ServerVersion::class),
$config,
Server::get(IAppConfig::class),
\OC::$server->getIntegrityCodeChecker(),
Server::get(Checker::class),
Server::get(LoggerInterface::class),
Server::get(\OC\Installer::class)
Server::get(Installer::class)
);
$incompatibleApps = [];
$incompatibleOverwrites = $config->getSystemValue('app_install_overwrite', []);
/** @var IEventDispatcher $dispatcher */
$dispatcher = \OC::$server->get(IEventDispatcher::class);
$dispatcher = Server::get(IEventDispatcher::class);
$dispatcher->addListener(
MigratorExecuteSqlEvent::class,
function (MigratorExecuteSqlEvent $event) use ($eventSource, $l): void {
@ -118,50 +124,50 @@ if (\OCP\Util::needUpgrade()) {
$dispatcher->addListener(RepairWarningEvent::class, [$feedBack, 'handleRepairFeedback']);
$dispatcher->addListener(RepairErrorEvent::class, [$feedBack, 'handleRepairFeedback']);
$updater->listen('\OC\Updater', 'maintenanceEnabled', function () use ($eventSource, $l) {
$updater->listen('\OC\Updater', 'maintenanceEnabled', function () use ($eventSource, $l): void {
$eventSource->send('success', $l->t('Turned on maintenance mode'));
});
$updater->listen('\OC\Updater', 'maintenanceDisabled', function () use ($eventSource, $l) {
$updater->listen('\OC\Updater', 'maintenanceDisabled', function () use ($eventSource, $l): void {
$eventSource->send('success', $l->t('Turned off maintenance mode'));
});
$updater->listen('\OC\Updater', 'maintenanceActive', function () use ($eventSource, $l) {
$updater->listen('\OC\Updater', 'maintenanceActive', function () use ($eventSource, $l): void {
$eventSource->send('success', $l->t('Maintenance mode is kept active'));
});
$updater->listen('\OC\Updater', 'dbUpgradeBefore', function () use ($eventSource, $l) {
$updater->listen('\OC\Updater', 'dbUpgradeBefore', function () use ($eventSource, $l): void {
$eventSource->send('success', $l->t('Updating database schema'));
});
$updater->listen('\OC\Updater', 'dbUpgrade', function () use ($eventSource, $l) {
$updater->listen('\OC\Updater', 'dbUpgrade', function () use ($eventSource, $l): void {
$eventSource->send('success', $l->t('Updated database'));
});
$updater->listen('\OC\Updater', 'upgradeAppStoreApp', function ($app) use ($eventSource, $l) {
$updater->listen('\OC\Updater', 'upgradeAppStoreApp', function ($app) use ($eventSource, $l): void {
$eventSource->send('success', $l->t('Update app "%s" from App Store', [$app]));
});
$updater->listen('\OC\Updater', 'appSimulateUpdate', function ($app) use ($eventSource, $l) {
$updater->listen('\OC\Updater', 'appSimulateUpdate', function ($app) use ($eventSource, $l): void {
$eventSource->send('success', $l->t('Checking whether the database schema for %s can be updated (this can take a long time depending on the database size)', [$app]));
});
$updater->listen('\OC\Updater', 'appUpgrade', function ($app, $version) use ($eventSource, $l) {
$updater->listen('\OC\Updater', 'appUpgrade', function ($app, $version) use ($eventSource, $l): void {
$eventSource->send('success', $l->t('Updated "%1$s" to %2$s', [$app, $version]));
});
$updater->listen('\OC\Updater', 'incompatibleAppDisabled', function ($app) use (&$incompatibleApps, &$incompatibleOverwrites) {
$updater->listen('\OC\Updater', 'incompatibleAppDisabled', function ($app) use (&$incompatibleApps, &$incompatibleOverwrites): void {
if (!in_array($app, $incompatibleOverwrites)) {
$incompatibleApps[] = $app;
}
});
$updater->listen('\OC\Updater', 'failure', function ($message) use ($eventSource, $config) {
$updater->listen('\OC\Updater', 'failure', function ($message) use ($eventSource, $config): void {
$eventSource->send('failure', $message);
$eventSource->close();
$config->setSystemValue('maintenance', false);
});
$updater->listen('\OC\Updater', 'setDebugLogLevel', function ($logLevel, $logLevelName) use ($eventSource, $l) {
$updater->listen('\OC\Updater', 'setDebugLogLevel', function ($logLevel, $logLevelName) use ($eventSource, $l): void {
$eventSource->send('success', $l->t('Set log level to debug'));
});
$updater->listen('\OC\Updater', 'resetLogLevel', function ($logLevel, $logLevelName) use ($eventSource, $l) {
$updater->listen('\OC\Updater', 'resetLogLevel', function ($logLevel, $logLevelName) use ($eventSource, $l): void {
$eventSource->send('success', $l->t('Reset log level'));
});
$updater->listen('\OC\Updater', 'startCheckCodeIntegrity', function () use ($eventSource, $l) {
$updater->listen('\OC\Updater', 'startCheckCodeIntegrity', function () use ($eventSource, $l): void {
$eventSource->send('success', $l->t('Starting code integrity check'));
});
$updater->listen('\OC\Updater', 'finishedCheckCodeIntegrity', function () use ($eventSource, $l) {
$updater->listen('\OC\Updater', 'finishedCheckCodeIntegrity', function () use ($eventSource, $l): void {
$eventSource->send('success', $l->t('Finished code integrity check'));
});

267
core/register_command.php

@ -8,150 +8,237 @@ declare(strict_types=1);
* SPDX-License-Identifier: AGPL-3.0-only
*/
use OC\Core\Command;
use OC\Core\Command\App\Disable;
use OC\Core\Command\App\Enable;
use OC\Core\Command\App\GetPath;
use OC\Core\Command\App\Install;
use OC\Core\Command\App\ListApps;
use OC\Core\Command\App\Remove;
use OC\Core\Command\App\Update;
use OC\Core\Command\Background\Delete;
use OC\Core\Command\Background\Job;
use OC\Core\Command\Background\JobWorker;
use OC\Core\Command\Background\ListCommand;
use OC\Core\Command\Background\Mode;
use OC\Core\Command\Broadcast\Test;
use OC\Core\Command\Check;
use OC\Core\Command\Config\App\DeleteConfig;
use OC\Core\Command\Config\App\GetConfig;
use OC\Core\Command\Config\App\SetConfig;
use OC\Core\Command\Config\Import;
use OC\Core\Command\Config\ListConfigs;
use OC\Core\Command\Db\AddMissingColumns;
use OC\Core\Command\Db\AddMissingIndices;
use OC\Core\Command\Db\AddMissingPrimaryKeys;
use OC\Core\Command\Db\ConvertFilecacheBigInt;
use OC\Core\Command\Db\ConvertMysqlToMB4;
use OC\Core\Command\Db\ConvertType;
use OC\Core\Command\Db\ExpectedSchema;
use OC\Core\Command\Db\ExportSchema;
use OC\Core\Command\Db\Migrations\ExecuteCommand;
use OC\Core\Command\Db\Migrations\GenerateCommand;
use OC\Core\Command\Db\Migrations\GenerateMetadataCommand;
use OC\Core\Command\Db\Migrations\MigrateCommand;
use OC\Core\Command\Db\Migrations\PreviewCommand;
use OC\Core\Command\Db\Migrations\StatusCommand;
use OC\Core\Command\Encryption\ChangeKeyStorageRoot;
use OC\Core\Command\Encryption\DecryptAll;
use OC\Core\Command\Encryption\EncryptAll;
use OC\Core\Command\Encryption\ListModules;
use OC\Core\Command\Encryption\MigrateKeyStorage;
use OC\Core\Command\Encryption\SetDefaultModule;
use OC\Core\Command\Encryption\ShowKeyStorageRoot;
use OC\Core\Command\FilesMetadata\Get;
use OC\Core\Command\Group\AddUser;
use OC\Core\Command\Group\RemoveUser;
use OC\Core\Command\Info\File;
use OC\Core\Command\Info\Space;
use OC\Core\Command\Integrity\CheckApp;
use OC\Core\Command\Integrity\CheckCore;
use OC\Core\Command\Integrity\SignApp;
use OC\Core\Command\Integrity\SignCore;
use OC\Core\Command\L10n\CreateJs;
use OC\Core\Command\Log\Manage;
use OC\Core\Command\Maintenance\DataFingerprint;
use OC\Core\Command\Maintenance\Mimetype\UpdateDB;
use OC\Core\Command\Maintenance\Mimetype\UpdateJS;
use OC\Core\Command\Maintenance\Repair;
use OC\Core\Command\Maintenance\RepairShareOwnership;
use OC\Core\Command\Maintenance\UpdateHtaccess;
use OC\Core\Command\Maintenance\UpdateTheme;
use OC\Core\Command\Memcache\RedisCommand;
use OC\Core\Command\Preview\Generate;
use OC\Core\Command\Preview\ResetRenderedTexts;
use OC\Core\Command\Security\BruteforceAttempts;
use OC\Core\Command\Security\BruteforceResetAttempts;
use OC\Core\Command\Security\ExportCertificates;
use OC\Core\Command\Security\ImportCertificate;
use OC\Core\Command\Security\ListCertificates;
use OC\Core\Command\Security\RemoveCertificate;
use OC\Core\Command\SetupChecks;
use OC\Core\Command\Status;
use OC\Core\Command\SystemTag\Edit;
use OC\Core\Command\TaskProcessing\EnabledCommand;
use OC\Core\Command\TaskProcessing\GetCommand;
use OC\Core\Command\TaskProcessing\Statistics;
use OC\Core\Command\TwoFactorAuth\Cleanup;
use OC\Core\Command\TwoFactorAuth\Enforce;
use OC\Core\Command\TwoFactorAuth\State;
use OC\Core\Command\Upgrade;
use OC\Core\Command\User\Add;
use OC\Core\Command\User\ClearGeneratedAvatarCacheCommand;
use OC\Core\Command\User\Info;
use OC\Core\Command\User\Keys\Verify;
use OC\Core\Command\User\LastSeen;
use OC\Core\Command\User\Report;
use OC\Core\Command\User\ResetPassword;
use OC\Core\Command\User\Setting;
use OC\Core\Command\User\SyncAccountDataCommand;
use OC\Core\Command\User\Welcome;
use OCP\IConfig;
use OCP\Server;
use Stecman\Component\Symfony\Console\BashCompletion\CompletionCommand;
$application->add(new CompletionCommand());
$application->add(Server::get(Command\Status::class));
$application->add(Server::get(Command\Check::class));
$application->add(Server::get(Command\L10n\CreateJs::class));
$application->add(Server::get(Command\Integrity\SignApp::class));
$application->add(Server::get(Command\Integrity\SignCore::class));
$application->add(Server::get(Command\Integrity\CheckApp::class));
$application->add(Server::get(Command\Integrity\CheckCore::class));
$application->add(Server::get(Status::class));
$application->add(Server::get(Check::class));
$application->add(Server::get(CreateJs::class));
$application->add(Server::get(SignApp::class));
$application->add(Server::get(SignCore::class));
$application->add(Server::get(CheckApp::class));
$application->add(Server::get(CheckCore::class));
$config = Server::get(IConfig::class);
if ($config->getSystemValueBool('installed', false)) {
$application->add(Server::get(Command\App\Disable::class));
$application->add(Server::get(Command\App\Enable::class));
$application->add(Server::get(Command\App\Install::class));
$application->add(Server::get(Command\App\GetPath::class));
$application->add(Server::get(Command\App\ListApps::class));
$application->add(Server::get(Command\App\Remove::class));
$application->add(Server::get(Command\App\Update::class));
$application->add(Server::get(Command\TwoFactorAuth\Cleanup::class));
$application->add(Server::get(Command\TwoFactorAuth\Enforce::class));
$application->add(Server::get(Disable::class));
$application->add(Server::get(Enable::class));
$application->add(Server::get(Install::class));
$application->add(Server::get(GetPath::class));
$application->add(Server::get(ListApps::class));
$application->add(Server::get(Remove::class));
$application->add(Server::get(Update::class));
$application->add(Server::get(Cleanup::class));
$application->add(Server::get(Enforce::class));
$application->add(Server::get(Command\TwoFactorAuth\Enable::class));
$application->add(Server::get(Command\TwoFactorAuth\Disable::class));
$application->add(Server::get(Command\TwoFactorAuth\State::class));
$application->add(Server::get(State::class));
$application->add(Server::get(Command\Background\Mode::class));
$application->add(Server::get(Command\Background\Job::class));
$application->add(Server::get(Command\Background\ListCommand::class));
$application->add(Server::get(Command\Background\Delete::class));
$application->add(Server::get(Command\Background\JobWorker::class));
$application->add(Server::get(Mode::class));
$application->add(Server::get(Job::class));
$application->add(Server::get(ListCommand::class));
$application->add(Server::get(Delete::class));
$application->add(Server::get(JobWorker::class));
$application->add(Server::get(Command\Broadcast\Test::class));
$application->add(Server::get(Test::class));
$application->add(Server::get(Command\Config\App\DeleteConfig::class));
$application->add(Server::get(Command\Config\App\GetConfig::class));
$application->add(Server::get(Command\Config\App\SetConfig::class));
$application->add(Server::get(Command\Config\Import::class));
$application->add(Server::get(Command\Config\ListConfigs::class));
$application->add(Server::get(DeleteConfig::class));
$application->add(Server::get(GetConfig::class));
$application->add(Server::get(SetConfig::class));
$application->add(Server::get(Import::class));
$application->add(Server::get(ListConfigs::class));
$application->add(Server::get(Command\Config\System\DeleteConfig::class));
$application->add(Server::get(Command\Config\System\GetConfig::class));
$application->add(Server::get(Command\Config\System\SetConfig::class));
$application->add(Server::get(Command\Info\File::class));
$application->add(Server::get(Command\Info\Space::class));
$application->add(Server::get(File::class));
$application->add(Server::get(Space::class));
$application->add(Server::get(Command\Db\ConvertType::class));
$application->add(Server::get(Command\Db\ConvertMysqlToMB4::class));
$application->add(Server::get(Command\Db\ConvertFilecacheBigInt::class));
$application->add(Server::get(Command\Db\AddMissingColumns::class));
$application->add(Server::get(Command\Db\AddMissingIndices::class));
$application->add(Server::get(Command\Db\AddMissingPrimaryKeys::class));
$application->add(Server::get(Command\Db\ExpectedSchema::class));
$application->add(Server::get(Command\Db\ExportSchema::class));
$application->add(Server::get(ConvertType::class));
$application->add(Server::get(ConvertMysqlToMB4::class));
$application->add(Server::get(ConvertFilecacheBigInt::class));
$application->add(Server::get(AddMissingColumns::class));
$application->add(Server::get(AddMissingIndices::class));
$application->add(Server::get(AddMissingPrimaryKeys::class));
$application->add(Server::get(ExpectedSchema::class));
$application->add(Server::get(ExportSchema::class));
$application->add(Server::get(Command\Db\Migrations\GenerateMetadataCommand::class));
$application->add(Server::get(Command\Db\Migrations\PreviewCommand::class));
$application->add(Server::get(GenerateMetadataCommand::class));
$application->add(Server::get(PreviewCommand::class));
if ($config->getSystemValueBool('debug', false)) {
$application->add(Server::get(Command\Db\Migrations\StatusCommand::class));
$application->add(Server::get(Command\Db\Migrations\MigrateCommand::class));
$application->add(Server::get(Command\Db\Migrations\GenerateCommand::class));
$application->add(Server::get(Command\Db\Migrations\ExecuteCommand::class));
$application->add(Server::get(StatusCommand::class));
$application->add(Server::get(MigrateCommand::class));
$application->add(Server::get(GenerateCommand::class));
$application->add(Server::get(ExecuteCommand::class));
}
$application->add(Server::get(Command\Encryption\Disable::class));
$application->add(Server::get(Command\Encryption\Enable::class));
$application->add(Server::get(Command\Encryption\ListModules::class));
$application->add(Server::get(Command\Encryption\SetDefaultModule::class));
$application->add(Server::get(ListModules::class));
$application->add(Server::get(SetDefaultModule::class));
$application->add(Server::get(Command\Encryption\Status::class));
$application->add(Server::get(Command\Encryption\EncryptAll::class));
$application->add(Server::get(Command\Encryption\DecryptAll::class));
$application->add(Server::get(EncryptAll::class));
$application->add(Server::get(DecryptAll::class));
$application->add(Server::get(Command\Log\Manage::class));
$application->add(Server::get(Manage::class));
$application->add(Server::get(Command\Log\File::class));
$application->add(Server::get(Command\Encryption\ChangeKeyStorageRoot::class));
$application->add(Server::get(Command\Encryption\ShowKeyStorageRoot::class));
$application->add(Server::get(Command\Encryption\MigrateKeyStorage::class));
$application->add(Server::get(ChangeKeyStorageRoot::class));
$application->add(Server::get(ShowKeyStorageRoot::class));
$application->add(Server::get(MigrateKeyStorage::class));
$application->add(Server::get(Command\Maintenance\DataFingerprint::class));
$application->add(Server::get(Command\Maintenance\Mimetype\UpdateDB::class));
$application->add(Server::get(Command\Maintenance\Mimetype\UpdateJS::class));
$application->add(Server::get(DataFingerprint::class));
$application->add(Server::get(UpdateDB::class));
$application->add(Server::get(UpdateJS::class));
$application->add(Server::get(Command\Maintenance\Mode::class));
$application->add(Server::get(Command\Maintenance\UpdateHtaccess::class));
$application->add(Server::get(Command\Maintenance\UpdateTheme::class));
$application->add(Server::get(UpdateHtaccess::class));
$application->add(Server::get(UpdateTheme::class));
$application->add(Server::get(Command\Upgrade::class));
$application->add(Server::get(Command\Maintenance\Repair::class));
$application->add(Server::get(Command\Maintenance\RepairShareOwnership::class));
$application->add(Server::get(Upgrade::class));
$application->add(Server::get(Repair::class));
$application->add(Server::get(RepairShareOwnership::class));
$application->add(Server::get(Command\Preview\Cleanup::class));
$application->add(Server::get(Command\Preview\Generate::class));
$application->add(Server::get(Generate::class));
$application->add(Server::get(Command\Preview\Repair::class));
$application->add(Server::get(Command\Preview\ResetRenderedTexts::class));
$application->add(Server::get(ResetRenderedTexts::class));
$application->add(Server::get(Command\User\Add::class));
$application->add(Server::get(Add::class));
$application->add(Server::get(Command\User\Delete::class));
$application->add(Server::get(Command\User\Disable::class));
$application->add(Server::get(Command\User\Enable::class));
$application->add(Server::get(Command\User\LastSeen::class));
$application->add(Server::get(Command\User\Report::class));
$application->add(Server::get(Command\User\ResetPassword::class));
$application->add(Server::get(Command\User\Setting::class));
$application->add(Server::get(LastSeen::class));
$application->add(Server::get(Report::class));
$application->add(Server::get(ResetPassword::class));
$application->add(Server::get(Setting::class));
$application->add(Server::get(Command\User\ListCommand::class));
$application->add(Server::get(Command\User\ClearGeneratedAvatarCacheCommand::class));
$application->add(Server::get(Command\User\Info::class));
$application->add(Server::get(Command\User\SyncAccountDataCommand::class));
$application->add(Server::get(ClearGeneratedAvatarCacheCommand::class));
$application->add(Server::get(Info::class));
$application->add(Server::get(SyncAccountDataCommand::class));
$application->add(Server::get(Command\User\AuthTokens\Add::class));
$application->add(Server::get(Command\User\AuthTokens\ListCommand::class));
$application->add(Server::get(Command\User\AuthTokens\Delete::class));
$application->add(Server::get(Command\User\Keys\Verify::class));
$application->add(Server::get(Command\User\Welcome::class));
$application->add(Server::get(Verify::class));
$application->add(Server::get(Welcome::class));
$application->add(Server::get(Command\Group\Add::class));
$application->add(Server::get(Command\Group\Delete::class));
$application->add(Server::get(Command\Group\ListCommand::class));
$application->add(Server::get(Command\Group\AddUser::class));
$application->add(Server::get(Command\Group\RemoveUser::class));
$application->add(Server::get(AddUser::class));
$application->add(Server::get(RemoveUser::class));
$application->add(Server::get(Command\Group\Info::class));
$application->add(Server::get(Command\SystemTag\ListCommand::class));
$application->add(Server::get(Command\SystemTag\Delete::class));
$application->add(Server::get(Command\SystemTag\Add::class));
$application->add(Server::get(Command\SystemTag\Edit::class));
$application->add(Server::get(Command\Security\ListCertificates::class));
$application->add(Server::get(Command\Security\ExportCertificates::class));
$application->add(Server::get(Command\Security\ImportCertificate::class));
$application->add(Server::get(Command\Security\RemoveCertificate::class));
$application->add(Server::get(Command\Security\BruteforceAttempts::class));
$application->add(Server::get(Command\Security\BruteforceResetAttempts::class));
$application->add(Server::get(Command\SetupChecks::class));
$application->add(Server::get(Command\FilesMetadata\Get::class));
$application->add(Server::get(Command\TaskProcessing\GetCommand::class));
$application->add(Server::get(Command\TaskProcessing\EnabledCommand::class));
$application->add(Server::get(Edit::class));
$application->add(Server::get(ListCertificates::class));
$application->add(Server::get(ExportCertificates::class));
$application->add(Server::get(ImportCertificate::class));
$application->add(Server::get(RemoveCertificate::class));
$application->add(Server::get(BruteforceAttempts::class));
$application->add(Server::get(BruteforceResetAttempts::class));
$application->add(Server::get(SetupChecks::class));
$application->add(Server::get(Get::class));
$application->add(Server::get(GetCommand::class));
$application->add(Server::get(EnabledCommand::class));
$application->add(Server::get(Command\TaskProcessing\ListCommand::class));
$application->add(Server::get(Command\TaskProcessing\Statistics::class));
$application->add(Server::get(Statistics::class));
$application->add(Server::get(Command\Memcache\RedisCommand::class));
$application->add(Server::get(RedisCommand::class));
} else {
$application->add(Server::get(Command\Maintenance\Install::class));
}

4
core/strings.php

@ -2,13 +2,15 @@
declare(strict_types=1);
use OCP\Util;
/**
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2011-2016 ownCloud, Inc.
* SPDX-License-Identifier: AGPL-3.0-only
*/
//some strings that are used in /lib but won't be translatable unless they are in /core too
$l = \OCP\Util::getL10N('core');
$l = Util::getL10N('core');
$l->t('Personal');
$l->t('Accounts');
$l->t('Apps');

2
core/templates/403.php

@ -8,7 +8,7 @@
if (!isset($_)) {//standalone page is not supported anymore - redirect to /
require_once '../../lib/base.php';
$urlGenerator = \OC::$server->getURLGenerator();
$urlGenerator = \OCP\Server::get(\OCP\IURLGenerator::class);
header('Location: ' . $urlGenerator->getAbsoluteURL('/'));
exit;
}

4
core/templates/404.php

@ -11,7 +11,7 @@
if (!isset($_)) {//standalone page is not supported anymore - redirect to /
require_once '../../lib/base.php';
$urlGenerator = \OC::$server->getURLGenerator();
$urlGenerator = \OCP\Server::get(\OCP\IURLGenerator::class);
header('Location: ' . $urlGenerator->getAbsoluteURL('/'));
exit;
}
@ -24,7 +24,7 @@ if (!isset($_)) {//standalone page is not supported anymore - redirect to /
<div class="icon-big icon-search"></div>
<h2><?php p($l->t('Page not found')); ?></h2>
<p class="infogroup"><?php p($l->t('The page could not be found on the server or you may not be allowed to view it.')); ?></p>
<p><a class="button primary" href="<?php p(\OC::$server->getURLGenerator()->linkTo('', 'index.php')) ?>">
<p><a class="button primary" href="<?php p(\OCP\Server::get(\OCP\IURLGenerator::class)->linkTo('', 'index.php')) ?>">
<?php p($l->t('Back to %s', [$theme->getName()])); ?>
</a></p>
</div>

2
core/templates/layout.user.php

@ -11,7 +11,7 @@
*/
$getUserAvatar = static function (int $size) use ($_): string {
return \OC::$server->getURLGenerator()->linkToRoute('core.avatar.getAvatar', [
return \OCP\Server::get(\OCP\IURLGenerator::class)->linkToRoute('core.avatar.getAvatar', [
'userId' => $_['user_uid'],
'size' => $size,
'v' => $_['userAvatarVersion']

2
core/templates/login.php

@ -7,7 +7,7 @@
*
* @var \OCP\IL10N $l
*/
script('core', 'login');
\OCP\Util::addScript('core', 'login', 'core');
?>
<div>
<div id="login"></div>

2
core/templates/loginflow/authpicker.php

@ -4,7 +4,7 @@
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
script('core', 'login/authpicker');
\OCP\Util::addScript('core', 'login/authpicker', 'core');
style('core', 'login/authpicker');
/** @var array $_ */

2
core/templates/loginflow/grant.php

@ -4,7 +4,7 @@
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
script('core', 'login/grant');
\OCP\Util::addScript('core', 'login/grant', 'core');
style('core', 'login/authpicker');
/** @var array $_ */

2
core/templates/loginflowv2/authpicker.php

@ -5,7 +5,7 @@
*/
style('core', 'login/authpicker');
script('core', 'login/authpicker');
\OCP\Util::addScript('core', 'login/authpicker', 'core');
/** @var array $_ */
/** @var \OCP\IURLGenerator $urlGenerator */

2
core/templates/loginflowv2/grant.php

@ -4,7 +4,7 @@
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
script('core', 'login/grant');
\OCP\Util::addScript('core', 'login/grant', 'core');
style('core', 'login/authpicker');
/** @var array $_ */

6
core/templates/print_exception.php

@ -1,11 +1,13 @@
<?php
use OCP\IL10N;
/**
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2012-2015 ownCloud, Inc.
* SPDX-License-Identifier: AGPL-3.0-only
*/
function print_exception(Throwable $e, \OCP\IL10N $l): void {
function print_exception(Throwable $e, IL10N $l): void {
print_unescaped('<pre>');
p($e->getTraceAsString());
print_unescaped('</pre>');

6
core/templates/print_xml_exception.php

@ -1,11 +1,13 @@
<?php
use OCP\IL10N;
/**
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2012-2015 ownCloud, Inc.
* SPDX-License-Identifier: AGPL-3.0-only
*/
function print_exception(Throwable $e, \OCP\IL10N $l): void {
function print_exception(Throwable $e, IL10N $l): void {
p($e->getTraceAsString());
if ($e->getPrevious() !== null) {

2
core/templates/recommendedapps.php

@ -5,7 +5,7 @@
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
script('core', 'recommendedapps');
\OCP\Util::addScript('core', 'recommendedapps', 'core');
?>

2
core/templates/success.php

@ -11,7 +11,7 @@
<div class="update">
<h2><?php p($_['title']) ?></h2>
<p><?php p($_['message']) ?></p>
<p><a class="button primary" href="<?php p(\OC::$server->get(\OCP\IURLGenerator::class)->linkTo('', 'index.php')) ?>">
<p><a class="button primary" href="<?php p(\OCP\Server::get(\OCP\IURLGenerator::class)->linkTo('', 'index.php')) ?>">
<?php p($l->t('Go to %s', [$theme->getName()])); ?>
</a></p>
</div>

6
core/templates/twofactorselectchallenge.php

@ -24,7 +24,7 @@ $noProviders = empty($_['providers']);
<strong><?php p($l->t('Two-factor authentication is enforced but has not been configured on your account. Contact your admin for assistance.')) ?></strong>
<?php } else { ?>
<strong><?php p($l->t('Two-factor authentication is enforced but has not been configured on your account. Please continue to setup two-factor authentication.')) ?></strong>
<a class="button primary two-factor-primary" href="<?php p(\OC::$server->getURLGenerator()->linkToRoute('core.TwoFactorChallenge.setupProviders',
<a class="button primary two-factor-primary" href="<?php p(\OCP\Server::get(\OCP\IURLGenerator::class)->linkToRoute('core.TwoFactorChallenge.setupProviders',
[
'redirect_url' => $_['redirect_url'],
]
@ -41,7 +41,7 @@ $noProviders = empty($_['providers']);
<?php foreach ($_['providers'] as $provider): ?>
<li>
<a class="two-factor-provider"
href="<?php p(\OC::$server->getURLGenerator()->linkToRoute('core.TwoFactorChallenge.showChallenge',
href="<?php p(\OCP\Server::get(\OCP\IURLGenerator::class)->linkToRoute('core.TwoFactorChallenge.showChallenge',
[
'challengeProviderId' => $provider->getId(),
'redirect_url' => $_['redirect_url'],
@ -66,7 +66,7 @@ $noProviders = empty($_['providers']);
<?php endif ?>
<?php if (!is_null($_['backupProvider'])): ?>
<p>
<a class="<?php if ($noProviders): ?>button primary two-factor-primary<?php else: ?>two-factor-secondary<?php endif ?>" href="<?php p(\OC::$server->getURLGenerator()->linkToRoute('core.TwoFactorChallenge.showChallenge',
<a class="<?php if ($noProviders): ?>button primary two-factor-primary<?php else: ?>two-factor-secondary<?php endif ?>" href="<?php p(\OCP\Server::get(\OCP\IURLGenerator::class)->linkToRoute('core.TwoFactorChallenge.showChallenge',
[
'challengeProviderId' => $_['backupProvider']->getId(),
'redirect_url' => $_['redirect_url'],

2
core/templates/twofactorsetupselection.php

@ -13,7 +13,7 @@ declare(strict_types=1);
<?php foreach ($_['providers'] as $provider): ?>
<li>
<a class="two-factor-provider"
href="<?php p(\OC::$server->getURLGenerator()->linkToRoute('core.TwoFactorChallenge.setupProvider',
href="<?php p(\OCP\Server::get(\OCP\IURLGenerator::class)->linkToRoute('core.TwoFactorChallenge.setupProvider',
[
'providerId' => $provider->getId(),
'redirect_url' => $_['redirect_url'],

2
core/templates/twofactorshowchallenge.php

@ -28,7 +28,7 @@ $template = $_['template'];
<?php print_unescaped($template); ?>
<?php if (!is_null($_['backupProvider'])): ?>
<p>
<a class="two-factor-secondary" href="<?php p(\OC::$server->getURLGenerator()->linkToRoute('core.TwoFactorChallenge.showChallenge',
<a class="two-factor-secondary" href="<?php p(\OCP\Server::get(\OCP\IURLGenerator::class)->linkToRoute('core.TwoFactorChallenge.showChallenge',
[
'challengeProviderId' => $_['backupProvider']->getId(),
'redirect_url' => $_['redirect_url'],

Loading…
Cancel
Save