diff --git a/apps/files/composer/composer/autoload_classmap.php b/apps/files/composer/composer/autoload_classmap.php index d7511e772abbf..b6affe4ad0907 100644 --- a/apps/files/composer/composer/autoload_classmap.php +++ b/apps/files/composer/composer/autoload_classmap.php @@ -17,7 +17,6 @@ 'OCA\\Files\\Activity\\Settings\\FileChanged' => $baseDir . '/../lib/Activity/Settings/FileChanged.php', 'OCA\\Files\\Activity\\Settings\\FileFavoriteChanged' => $baseDir . '/../lib/Activity/Settings/FileFavoriteChanged.php', 'OCA\\Files\\AdvancedCapabilities' => $baseDir . '/../lib/AdvancedCapabilities.php', - 'OCA\\Files\\App' => $baseDir . '/../lib/App.php', 'OCA\\Files\\AppInfo\\Application' => $baseDir . '/../lib/AppInfo/Application.php', 'OCA\\Files\\BackgroundJob\\CleanupDirectEditingTokens' => $baseDir . '/../lib/BackgroundJob/CleanupDirectEditingTokens.php', 'OCA\\Files\\BackgroundJob\\CleanupFileLocks' => $baseDir . '/../lib/BackgroundJob/CleanupFileLocks.php', diff --git a/apps/files/composer/composer/autoload_static.php b/apps/files/composer/composer/autoload_static.php index ab2b19e7772c1..6014157f99242 100644 --- a/apps/files/composer/composer/autoload_static.php +++ b/apps/files/composer/composer/autoload_static.php @@ -32,7 +32,6 @@ class ComposerStaticInitFiles 'OCA\\Files\\Activity\\Settings\\FileChanged' => __DIR__ . '/..' . '/../lib/Activity/Settings/FileChanged.php', 'OCA\\Files\\Activity\\Settings\\FileFavoriteChanged' => __DIR__ . '/..' . '/../lib/Activity/Settings/FileFavoriteChanged.php', 'OCA\\Files\\AdvancedCapabilities' => __DIR__ . '/..' . '/../lib/AdvancedCapabilities.php', - 'OCA\\Files\\App' => __DIR__ . '/..' . '/../lib/App.php', 'OCA\\Files\\AppInfo\\Application' => __DIR__ . '/..' . '/../lib/AppInfo/Application.php', 'OCA\\Files\\BackgroundJob\\CleanupDirectEditingTokens' => __DIR__ . '/..' . '/../lib/BackgroundJob/CleanupDirectEditingTokens.php', 'OCA\\Files\\BackgroundJob\\CleanupFileLocks' => __DIR__ . '/..' . '/../lib/BackgroundJob/CleanupFileLocks.php', diff --git a/apps/files/lib/App.php b/apps/files/lib/App.php deleted file mode 100644 index 0326b670608a7..0000000000000 --- a/apps/files/lib/App.php +++ /dev/null @@ -1,22 +0,0 @@ - ChunkedUploadConfig::getMaxChunkSize(), - ]; - - $settings['array']['oc_appconfig'] = json_encode($appConfig); - } -} diff --git a/apps/files/lib/AppInfo/Application.php b/apps/files/lib/AppInfo/Application.php index ca05d50699324..359e9edcb1441 100644 --- a/apps/files/lib/AppInfo/Application.php +++ b/apps/files/lib/AppInfo/Application.php @@ -8,7 +8,6 @@ */ namespace OCA\Files\AppInfo; -use Closure; use OCA\Files\AdvancedCapabilities; use OCA\Files\Capabilities; use OCA\Files\Collaboration\Resources\Listener; @@ -50,12 +49,13 @@ use OCP\IL10N; use OCP\IPreview; use OCP\IRequest; -use OCP\IServerContainer; use OCP\ITagManager; use OCP\IUserSession; +use OCP\Share\Events\ShareCreatedEvent; +use OCP\Share\Events\ShareDeletedEvent; +use OCP\Share\Events\ShareDeletedFromSelfEvent; use OCP\Share\IManager as IShareManager; use OCP\User\Events\UserFirstTimeLoggedInEvent; -use OCP\Util; use Psr\Container\ContainerInterface; use Psr\Log\LoggerInterface; @@ -71,9 +71,12 @@ public function register(IRegistrationContext $context): void { /** * Controllers */ - $context->registerService('APIController', function (ContainerInterface $c) { - /** @var IServerContainer $server */ - $server = $c->get(IServerContainer::class); + $context->registerService(APIController::class, function (ContainerInterface $c): ApiController { + /** @var IUserSession $userSession */ + $userSession = $c->get(IUserSession::class); + + /** @var IRootFolder $rootFolder */ + $rootFolder = $c->get(IRootFolder::class); return new ApiController( $c->get('AppName'), @@ -83,7 +86,7 @@ public function register(IRegistrationContext $context): void { $c->get(IPreview::class), $c->get(IShareManager::class), $c->get(IConfig::class), - $server->getUserFolder(), + $rootFolder->getUserFolder($userSession->getUser()->getUID()), $c->get(UserConfig::class), $c->get(ViewConfig::class), $c->get(IL10N::class), @@ -95,15 +98,18 @@ public function register(IRegistrationContext $context): void { /** * Services */ - $context->registerService(TagService::class, function (ContainerInterface $c) { - /** @var IServerContainer $server */ - $server = $c->get(IServerContainer::class); + $context->registerService(TagService::class, function (ContainerInterface $c): TagService { + /** @var IUserSession $userSession */ + $userSession = $c->get(IUserSession::class); + + /** @var IRootFolder $rootFolder */ + $rootFolder = $c->get(IRootFolder::class); return new TagService( - $c->get(IUserSession::class), + $userSession, $c->get(IActivityManager::class), $c->get(ITagManager::class)->load(self::APP_ID), - $server->getUserFolder(), + $rootFolder->getUserFolder($userSession->getUser()->getUID()), ); }); @@ -126,6 +132,10 @@ public function register(IRegistrationContext $context): void { $context->registerEventListener(NodeRemovedFromFavorite::class, NodeRemovedFromFavoriteListener::class); $context->registerEventListener(UserFirstTimeLoggedInEvent::class, UserFirstTimeLoggedInListener::class); + $context->registerEventListener(ShareCreatedEvent::class, Listener::class); + $context->registerEventListener(ShareDeletedEvent::class, Listener::class); + $context->registerEventListener(ShareDeletedFromSelfEvent::class, Listener::class); + $context->registerSearchProvider(FilesSearchProvider::class); $context->registerNotifierService(Notifier::class); @@ -137,16 +147,10 @@ public function register(IRegistrationContext $context): void { #[\Override] public function boot(IBootContext $context): void { - $context->injectFn(Closure::fromCallable([$this, 'registerCollaboration'])); - $context->injectFn([Listener::class, 'register']); - $this->registerHooks(); + $context->injectFn($this->registerCollaboration(...)); } private function registerCollaboration(IProviderManager $providerManager): void { $providerManager->registerResourceProvider(ResourceProvider::class); } - - private function registerHooks(): void { - Util::connectHook('\OCP\Config', 'js', '\OCA\Files\App', 'extendJsConfig'); - } } diff --git a/apps/files/lib/BackgroundJob/ScanFiles.php b/apps/files/lib/BackgroundJob/ScanFiles.php index 445de92a4fb34..f29fec87056d6 100644 --- a/apps/files/lib/BackgroundJob/ScanFiles.php +++ b/apps/files/lib/BackgroundJob/ScanFiles.php @@ -56,7 +56,7 @@ protected function runScanner(string $user): void { } catch (\Exception $e) { $this->logger->error($e->getMessage(), ['exception' => $e, 'app' => 'files']); } - \OC_Util::tearDownFS(); + $this->setupManager->tearDown(); } /** @@ -127,7 +127,7 @@ private function getAllMountedStorages(): array { * @throws \Exception */ #[\Override] - protected function run($argument) { + protected function run($argument): void { if ($this->config->getSystemValueBool('files_no_background_scan', false)) { return; } diff --git a/apps/files/lib/Collaboration/Resources/Listener.php b/apps/files/lib/Collaboration/Resources/Listener.php index e4ff5d83b7af4..78c541d60acf6 100644 --- a/apps/files/lib/Collaboration/Resources/Listener.php +++ b/apps/files/lib/Collaboration/Resources/Listener.php @@ -9,25 +9,29 @@ namespace OCA\Files\Collaboration\Resources; use OCP\Collaboration\Resources\IManager; -use OCP\EventDispatcher\IEventDispatcher; -use OCP\Server; +use OCP\EventDispatcher\Event; +use OCP\EventDispatcher\IEventListener; use OCP\Share\Events\ShareCreatedEvent; use OCP\Share\Events\ShareDeletedEvent; use OCP\Share\Events\ShareDeletedFromSelfEvent; -class Listener { - public static function register(IEventDispatcher $dispatcher): void { - $dispatcher->addListener(ShareCreatedEvent::class, [self::class, 'shareModification']); - $dispatcher->addListener(ShareDeletedEvent::class, [self::class, 'shareModification']); - $dispatcher->addListener(ShareDeletedFromSelfEvent::class, [self::class, 'shareModification']); +/** + * @template-implements IEventListener + */ +class Listener implements IEventListener { + public function __construct( + readonly protected IManager $resourceManager, + readonly protected ResourceProvider $resourceProvider, + ) { } - public static function shareModification(): void { - /** @var IManager $resourceManager */ - $resourceManager = Server::get(IManager::class); - /** @var ResourceProvider $resourceProvider */ - $resourceProvider = Server::get(ResourceProvider::class); + public function handle(Event $event): void { + if ($event instanceof ShareDeletedFromSelfEvent || $event instanceof ShareDeletedEvent || $event instanceof ShareCreatedEvent) { + $this->shareModification(); + } + } - $resourceManager->invalidateAccessCacheForProvider($resourceProvider); + public function shareModification(): void { + $this->resourceManager->invalidateAccessCacheForProvider($this->resourceProvider); } } diff --git a/apps/files_sharing/lib/Listener/LoadAdditionalListener.php b/apps/files_sharing/lib/Listener/LoadAdditionalListener.php index 4ba3a0266ef96..f36c7e3d4e3e4 100644 --- a/apps/files_sharing/lib/Listener/LoadAdditionalListener.php +++ b/apps/files_sharing/lib/Listener/LoadAdditionalListener.php @@ -29,7 +29,7 @@ public function handle(Event $event): void { Util::addStyle(Application::APP_ID, 'icons'); $shareManager = Server::get(IManager::class); - if ($shareManager->shareApiEnabled() && class_exists('\OCA\Files\App')) { + if ($shareManager->shareApiEnabled()) { Util::addInitScript(Application::APP_ID, 'init'); } } diff --git a/build/psalm-baseline.xml b/build/psalm-baseline.xml index c6c6248d122ec..953767d2fa81a 100644 --- a/build/psalm-baseline.xml +++ b/build/psalm-baseline.xml @@ -1397,25 +1397,6 @@ fileIsEncrypted]]> - - - - - - - - - - - - - - - - - - - diff --git a/lib/private/Template/JSConfigHelper.php b/lib/private/Template/JSConfigHelper.php index 4907274f7304e..15a66954a2ab8 100644 --- a/lib/private/Template/JSConfigHelper.php +++ b/lib/private/Template/JSConfigHelper.php @@ -12,6 +12,7 @@ use OC\CapabilitiesManager; use OC\Core\AppInfo\ConfigLexicon; use OC\Files\FilenameValidator; +use OCA\Files\Service\ChunkedUploadConfig; use OCA\Provisioning_API\Controller\AUserDataOCSController; use OCP\App\AppPathNotFoundException; use OCP\App\IAppManager; @@ -256,7 +257,10 @@ public function getConfig(): string { 'defaultRemoteExpireDateEnabled' => $defaultRemoteExpireDateEnabled, 'defaultRemoteExpireDate' => $defaultRemoteExpireDate, 'defaultRemoteExpireDateEnforced' => $defaultRemoteExpireDateEnforced, - ] + ], + 'files' => [ + 'max_chunk_size' => ChunkedUploadConfig::getMaxChunkSize(), + ], ]), '_theme' => json_encode([ 'entity' => $this->defaults->getEntity(), @@ -287,9 +291,6 @@ public function getConfig(): string { $this->initialStateService->provideInitialState('core', 'config', $config); $this->initialStateService->provideInitialState('core', 'capabilities', $capabilities); - // Allow hooks to modify the output values - \OC_Hook::emit('\OCP\Config', 'js', ['array' => &$array]); - $result = ''; // Echo it