Skip to content

Commit 4a6fd95

Browse files
Merge pull request #51259 from nextcloud/bugfix/50619/no-session-work-in-constructor
fix(files): Don't do session related work in the constructor of the View
2 parents 62e7e29 + 3391279 commit 4a6fd95

1 file changed

Lines changed: 8 additions & 10 deletions

File tree

lib/private/Files/View.php

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
use OCP\Files\Mount\IMountPoint;
2929
use OCP\Files\NotFoundException;
3030
use OCP\Files\ReservedWordException;
31-
use OCP\IL10N;
3231
use OCP\IUser;
3332
use OCP\IUserManager;
3433
use OCP\L10N\IFactory;
@@ -62,7 +61,6 @@ class View {
6261
private bool $updaterEnabled = true;
6362
private UserManager $userManager;
6463
private LoggerInterface $logger;
65-
private IL10N $l10n;
6664

6765
/**
6866
* @throws \Exception If $root contains an invalid path
@@ -77,7 +75,6 @@ public function __construct(string $root = '') {
7775
$this->lockingEnabled = !($this->lockingProvider instanceof \OC\Lock\NoopLockingProvider);
7876
$this->userManager = \OC::$server->getUserManager();
7977
$this->logger = \OC::$server->get(LoggerInterface::class);
80-
$this->l10n = \OC::$server->get(IFactory::class)->get('files');
8178
}
8279

8380
/**
@@ -867,6 +864,7 @@ private function validateMountMove(array $mounts, IMountPoint $sourceMount, IMou
867864
$targetPath = $targetMount->getMountPoint();
868865
}
869866

867+
$l = \OC::$server->get(IFactory::class)->get('files');
870868
foreach ($mounts as $mount) {
871869
$sourcePath = $this->getRelativePath($mount->getMountPoint());
872870
if ($sourcePath) {
@@ -876,29 +874,29 @@ private function validateMountMove(array $mounts, IMountPoint $sourceMount, IMou
876874
}
877875

878876
if (!$mount instanceof MoveableMount) {
879-
throw new ForbiddenException($this->l10n->t('Storage %s cannot be moved', [$sourcePath]), false);
877+
throw new ForbiddenException($l->t('Storage %s cannot be moved', [$sourcePath]), false);
880878
}
881879

882880
if ($targetIsShared) {
883881
if ($sourceMount instanceof SharedMount) {
884-
throw new ForbiddenException($this->l10n->t('Moving a share (%s) into a shared folder is not allowed', [$sourcePath]), false);
882+
throw new ForbiddenException($l->t('Moving a share (%s) into a shared folder is not allowed', [$sourcePath]), false);
885883
} else {
886-
throw new ForbiddenException($this->l10n->t('Moving a storage (%s) into a shared folder is not allowed', [$sourcePath]), false);
884+
throw new ForbiddenException($l->t('Moving a storage (%s) into a shared folder is not allowed', [$sourcePath]), false);
887885
}
888886
}
889887

890888
if ($sourceMount !== $targetMount) {
891889
if ($sourceMount instanceof SharedMount) {
892890
if ($targetMount instanceof SharedMount) {
893-
throw new ForbiddenException($this->l10n->t('Moving a share (%s) into another share (%s) is not allowed', [$sourcePath, $targetPath]), false);
891+
throw new ForbiddenException($l->t('Moving a share (%s) into another share (%s) is not allowed', [$sourcePath, $targetPath]), false);
894892
} else {
895-
throw new ForbiddenException($this->l10n->t('Moving a share (%s) into another storage (%s) is not allowed', [$sourcePath, $targetPath]), false);
893+
throw new ForbiddenException($l->t('Moving a share (%s) into another storage (%s) is not allowed', [$sourcePath, $targetPath]), false);
896894
}
897895
} else {
898896
if ($targetMount instanceof SharedMount) {
899-
throw new ForbiddenException($this->l10n->t('Moving a storage (%s) into a share (%s) is not allowed', [$sourcePath, $targetPath]), false);
897+
throw new ForbiddenException($l->t('Moving a storage (%s) into a share (%s) is not allowed', [$sourcePath, $targetPath]), false);
900898
} else {
901-
throw new ForbiddenException($this->l10n->t('Moving a storage (%s) into another storage (%s) is not allowed', [$sourcePath, $targetPath]), false);
899+
throw new ForbiddenException($l->t('Moving a storage (%s) into another storage (%s) is not allowed', [$sourcePath, $targetPath]), false);
902900
}
903901
}
904902
}

0 commit comments

Comments
 (0)