From 93f039fb962f3eb32887fb8e48728433d6d90757 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 5 Mar 2025 08:59:32 +0100 Subject: [PATCH 1/2] fix(files): Don't do session related work in the constructor of the View Signed-off-by: Joas Schilling --- lib/private/Files/View.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/private/Files/View.php b/lib/private/Files/View.php index fea1f64707b64..6409ddbe986b9 100644 --- a/lib/private/Files/View.php +++ b/lib/private/Files/View.php @@ -28,7 +28,6 @@ use OCP\Files\Mount\IMountPoint; use OCP\Files\NotFoundException; use OCP\Files\ReservedWordException; -use OCP\IL10N; use OCP\IUser; use OCP\IUserManager; use OCP\L10N\IFactory; @@ -62,7 +61,7 @@ class View { private bool $updaterEnabled = true; private UserManager $userManager; private LoggerInterface $logger; - private IL10N $l10n; + private IFactory $l10nFactory; /** * @throws \Exception If $root contains an invalid path @@ -77,7 +76,7 @@ public function __construct(string $root = '') { $this->lockingEnabled = !($this->lockingProvider instanceof \OC\Lock\NoopLockingProvider); $this->userManager = \OC::$server->getUserManager(); $this->logger = \OC::$server->get(LoggerInterface::class); - $this->l10n = \OC::$server->get(IFactory::class)->get('files'); + $this->l10nFactory = \OC::$server->get(IFactory::class); } /** @@ -867,6 +866,7 @@ private function validateMountMove(array $mounts, IMountPoint $sourceMount, IMou $targetPath = $targetMount->getMountPoint(); } + $l = $this->l10nFactory->get('files'); foreach ($mounts as $mount) { $sourcePath = $this->getRelativePath($mount->getMountPoint()); if ($sourcePath) { @@ -876,29 +876,29 @@ private function validateMountMove(array $mounts, IMountPoint $sourceMount, IMou } if (!$mount instanceof MoveableMount) { - throw new ForbiddenException($this->l10n->t('Storage %s cannot be moved', [$sourcePath]), false); + throw new ForbiddenException($l->t('Storage %s cannot be moved', [$sourcePath]), false); } if ($targetIsShared) { if ($sourceMount instanceof SharedMount) { - throw new ForbiddenException($this->l10n->t('Moving a share (%s) into a shared folder is not allowed', [$sourcePath]), false); + throw new ForbiddenException($l->t('Moving a share (%s) into a shared folder is not allowed', [$sourcePath]), false); } else { - throw new ForbiddenException($this->l10n->t('Moving a storage (%s) into a shared folder is not allowed', [$sourcePath]), false); + throw new ForbiddenException($l->t('Moving a storage (%s) into a shared folder is not allowed', [$sourcePath]), false); } } if ($sourceMount !== $targetMount) { if ($sourceMount instanceof SharedMount) { if ($targetMount instanceof SharedMount) { - throw new ForbiddenException($this->l10n->t('Moving a share (%s) into another share (%s) is not allowed', [$sourcePath, $targetPath]), false); + throw new ForbiddenException($l->t('Moving a share (%s) into another share (%s) is not allowed', [$sourcePath, $targetPath]), false); } else { - throw new ForbiddenException($this->l10n->t('Moving a share (%s) into another storage (%s) is not allowed', [$sourcePath, $targetPath]), false); + throw new ForbiddenException($l->t('Moving a share (%s) into another storage (%s) is not allowed', [$sourcePath, $targetPath]), false); } } else { if ($targetMount instanceof SharedMount) { - throw new ForbiddenException($this->l10n->t('Moving a storage (%s) into a share (%s) is not allowed', [$sourcePath, $targetPath]), false); + throw new ForbiddenException($l->t('Moving a storage (%s) into a share (%s) is not allowed', [$sourcePath, $targetPath]), false); } else { - throw new ForbiddenException($this->l10n->t('Moving a storage (%s) into another storage (%s) is not allowed', [$sourcePath, $targetPath]), false); + throw new ForbiddenException($l->t('Moving a storage (%s) into another storage (%s) is not allowed', [$sourcePath, $targetPath]), false); } } } From 44e89610edf70b7f88bf4ac7c9bf2fec2a9a7bc3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcel=20M=C3=BCller?= Date: Wed, 5 Mar 2025 11:04:55 +0100 Subject: [PATCH 2/2] fix: No IFactory in constructor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Marcel Müller --- lib/private/Files/View.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/private/Files/View.php b/lib/private/Files/View.php index 6409ddbe986b9..bbad24d3e435f 100644 --- a/lib/private/Files/View.php +++ b/lib/private/Files/View.php @@ -61,7 +61,6 @@ class View { private bool $updaterEnabled = true; private UserManager $userManager; private LoggerInterface $logger; - private IFactory $l10nFactory; /** * @throws \Exception If $root contains an invalid path @@ -76,7 +75,6 @@ public function __construct(string $root = '') { $this->lockingEnabled = !($this->lockingProvider instanceof \OC\Lock\NoopLockingProvider); $this->userManager = \OC::$server->getUserManager(); $this->logger = \OC::$server->get(LoggerInterface::class); - $this->l10nFactory = \OC::$server->get(IFactory::class); } /** @@ -866,7 +864,7 @@ private function validateMountMove(array $mounts, IMountPoint $sourceMount, IMou $targetPath = $targetMount->getMountPoint(); } - $l = $this->l10nFactory->get('files'); + $l = \OC::$server->get(IFactory::class)->get('files'); foreach ($mounts as $mount) { $sourcePath = $this->getRelativePath($mount->getMountPoint()); if ($sourcePath) {