Skip to content

Commit 422dfaf

Browse files
Merge pull request #51279 from nextcloud/backport/51259/stable28
[stable28] fix(files): Don't do session related work in the constructor of the View
2 parents b8958be + 056d1fa commit 422dfaf

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
@@ -68,7 +68,6 @@
6868
use OCP\Files\NotFoundException;
6969
use OCP\Files\ReservedWordException;
7070
use OCP\Files\Storage\IStorage;
71-
use OCP\IL10N;
7271
use OCP\IUser;
7372
use OCP\L10N\IFactory;
7473
use OCP\Lock\ILockingProvider;
@@ -98,7 +97,6 @@ class View {
9897
private bool $updaterEnabled = true;
9998
private UserManager $userManager;
10099
private LoggerInterface $logger;
101-
private IL10N $l10n;
102100

103101
/**
104102
* @throws \Exception If $root contains an invalid path
@@ -113,7 +111,6 @@ public function __construct(string $root = '') {
113111
$this->lockingEnabled = !($this->lockingProvider instanceof \OC\Lock\NoopLockingProvider);
114112
$this->userManager = \OC::$server->getUserManager();
115113
$this->logger = \OC::$server->get(LoggerInterface::class);
116-
$this->l10n = \OC::$server->get(IFactory::class)->get('files');
117114
}
118115

119116
/**
@@ -893,6 +890,7 @@ private function validateMountMove(array $mounts, IMountPoint $sourceMount, IMou
893890
$targetPath = $targetMount->getMountPoint();
894891
}
895892

893+
$l = \OC::$server->get(IFactory::class)->get('files');
896894
foreach ($mounts as $mount) {
897895
$sourcePath = $this->getRelativePath($mount->getMountPoint());
898896
if ($sourcePath) {
@@ -902,29 +900,29 @@ private function validateMountMove(array $mounts, IMountPoint $sourceMount, IMou
902900
}
903901

904902
if (!$mount instanceof MoveableMount) {
905-
throw new ForbiddenException($this->l10n->t('Storage %s cannot be moved', [$sourcePath]), false);
903+
throw new ForbiddenException($l->t('Storage %s cannot be moved', [$sourcePath]), false);
906904
}
907905

908906
if ($targetIsShared) {
909907
if ($sourceMount instanceof SharedMount) {
910-
throw new ForbiddenException($this->l10n->t('Moving a share (%s) into a shared folder is not allowed', [$sourcePath]), false);
908+
throw new ForbiddenException($l->t('Moving a share (%s) into a shared folder is not allowed', [$sourcePath]), false);
911909
} else {
912-
throw new ForbiddenException($this->l10n->t('Moving a storage (%s) into a shared folder is not allowed', [$sourcePath]), false);
910+
throw new ForbiddenException($l->t('Moving a storage (%s) into a shared folder is not allowed', [$sourcePath]), false);
913911
}
914912
}
915913

916914
if ($sourceMount !== $targetMount) {
917915
if ($sourceMount instanceof SharedMount) {
918916
if ($targetMount instanceof SharedMount) {
919-
throw new ForbiddenException($this->l10n->t('Moving a share (%s) into another share (%s) is not allowed', [$sourcePath, $targetPath]), false);
917+
throw new ForbiddenException($l->t('Moving a share (%s) into another share (%s) is not allowed', [$sourcePath, $targetPath]), false);
920918
} else {
921-
throw new ForbiddenException($this->l10n->t('Moving a share (%s) into another storage (%s) is not allowed', [$sourcePath, $targetPath]), false);
919+
throw new ForbiddenException($l->t('Moving a share (%s) into another storage (%s) is not allowed', [$sourcePath, $targetPath]), false);
922920
}
923921
} else {
924922
if ($targetMount instanceof SharedMount) {
925-
throw new ForbiddenException($this->l10n->t('Moving a storage (%s) into a share (%s) is not allowed', [$sourcePath, $targetPath]), false);
923+
throw new ForbiddenException($l->t('Moving a storage (%s) into a share (%s) is not allowed', [$sourcePath, $targetPath]), false);
926924
} else {
927-
throw new ForbiddenException($this->l10n->t('Moving a storage (%s) into another storage (%s) is not allowed', [$sourcePath, $targetPath]), false);
925+
throw new ForbiddenException($l->t('Moving a storage (%s) into another storage (%s) is not allowed', [$sourcePath, $targetPath]), false);
928926
}
929927
}
930928
}

0 commit comments

Comments
 (0)